Bug 77358 - [F08] deferred-length character function returns zero-length string
Damian Rouson
damian@sourceryinstitute.org
Wed Aug 24 01:05:00 GMT 2016
I just submitted the following text in the above referenced bug report.
As shown below with gfotran 7.0, a deferred-length character function
returns a zero-length string when the function is implemented inside a
submodule. Either of the following eliminates the bug:
(1) moving the function from the submodule to the module or
(2) changing the deferred-length character declarations to fixed-length
declarations with or without the allocatable attribute.
It would be great if the fix could be backported to the 6 branch.
$ cat alloc-char-func-in-submodule.f90
module hello_interface
character(len=13) :: string="Hello, world!"
interface
module function get() result(result_string)
character(:), allocatable :: result_string
end function
end interface
end module
submodule(hello_interface) hello_implementation
contains
module function get() result(result_string)
character(:), allocatable :: result_string
result_string = string
end function
end submodule
use hello_interface
print *,len(get())
end
$ gfortran alloc-char-func-in-submodule.f90
$ ./a.out
0
$ gfortran --version
GNU Fortran (MacPorts gcc7 7-20160814_0) 7.0.0 20160814 (experimental)
Damian
More information about the Fortran
mailing list