https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70605
Bug ID: 70605 Summary: allocatable character scalar in type empty after assign Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: critical Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: nuclearlee at gmail dot com Target Milestone: --- Created attachment 38228 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38228&action=edit Testcode containing a program containing a subroutine that accepts a variable length character and an string (in) as an allocatable scalar (inout) I've found that if I pass an allocatable scalar character string (character(len=:), allocatable :: string) that is contained in a type to a subroutine, allocate it in the subroutine, set it, it is passed back as allocated, but it is empty. If I pass an allocatable scalar character to the same subroutine, but it is not in a type, the return is as expected. The test code I'm attaching contains a subroutine that concatenates an input string to an allocatable scalar character, and returns the concatenated string. I've tested in windows (from equation.com) and ubuntu with gfotran 4.8, 4.9 and 5.3, and all return the same empty string for the allocatable scalar in a type. I've also compiled it with ifort 16 (just checking to see if something compiles it correctly), and it returns correctly for both situations. In ubuntu compiled with the command gfortran-5 -std=f2008 -o call_test call_test.f90 and the results I get from the gcc 5.3: ~/testcode$ ./call_test_f.exe string_in, string_cat_with_comma result: hello, hello added hello to get str_len1, strlen2, tot_len: 7 0 8 string_in, string_cat_with_comma result: goodbye, ,goodbye added goodbye to get str_len1, strlen2, tot_len: 8 0 9 string_in, string_cat_with_comma result: waithere, ,waithere added waithere to get ********** string_in, string_cat_with_comma result: hello, hello added hello to get hello str_len1, strlen2, tot_len: 7 5 13 string_in, string_cat_with_comma result: goodbye, hello,goodbye added goodbye to get hello,goodbye str_len1, strlen2, tot_len: 8 13 22 string_in, string_cat_with_comma result: waithere, hello,goodbye,waithere added waithere to get hello,goodbye,waithere