[Bug fortran/47775] Error on allocatable array returned by function
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 17 07:53:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47775
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-02-17 07:33:55 UTC ---
If I try the example, I get a segmentation fault in m_string.F90's
string_to_char
The code looks as follows:
elemental function string_to_char( s ) result(res)
[...]
character(len=size(s%string)) :: res
[...]
if( allocated(s%string) ) then
res = transfer( s%string, res )
else
res = ''
end if
The crash happens in the "res =''" line and makes perfectly sense. If the
variable "s%string" is not allocated, it is not surprising that there is a
segfault:
"13.7.156 SIZE (ARRAY [, DIM, KIND])" [...]
"Arguments.
'ARRAY shall be an array of any type. It shall not be an unallocated
allocatable variable or a pointer that is not associated."
More information about the Gcc-bugs
mailing list