[Bug fortran/97176] Cannot return deferred length strings when using -fno-automatic
kargl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Sep 23 16:43:33 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97176
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org ---
Workaround 1.
Don't use -fno-automatic if you use a RESULT variable.
Workaround 2.
Don't use a RESULT variable.
Workaround 3.
Explicitly give entities the SAVE attribute whereby your
testfunc() becomes
function testfunc(string) result(res)
character(:), allocatable, save :: res
character(*), intent(in) :: string
res = string
end function testfunc
which leads to the informative error message
% gfcx -o z a.f90 && ./z
a.f90:10:42:
10 | character(:), allocatable, save :: res
| 1
Error: RESULT attribute conflicts with SAVE attribute at (1)
More information about the Gcc-bugs
mailing list