https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69495
--- Comment #9 from janus at gcc dot gnu.org --- Created attachment 37527 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37527&action=edit patch The attached patch should take care of all cases mentioned above. Unfortunately it causes a testsuite failure of elemental_optional_args_6.f90 and I just cannot understand why :(