[Bug fortran/126018] gfortran rejects character function invocation as stop code
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jun 28 06:00:22 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126018
--- Comment #2 from Steve Kargl <kargl at gcc dot gnu.org> ---
(In reply to Damian Rouson from comment #1)
> Switching from `error stop` to `stop` yields the same error message.
>
> The workaround is to assign the function result to a variable and then use
> the variable as the stop code.
There are other workaround. Here's one.
implicit none
character(len=1), external :: character_stop_code
error stop character_stop_code()
contains
end
function character_stop_code()
character(len=1) character_stop_code
character_stop_code = "a"
end function
The problem is the test for integer or character type occurs
before the contained function is resolved. In the above, the
functions return type is known before 'error stop' is parsed.
Putting character_stop_code() in a module and using the module
may also be a workaround.
More information about the Gcc-bugs
mailing list