https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111304
Bug ID: 111304 Summary: Problem when passing implicit arrays of characters to functions Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mailling-lists-bd at posteo dot de Target Milestone: --- Hi, In the following code, the first call to `func1` works as expected and prints the content of the array `my_directory`, while the second call, with the array defined directly in the function argument, leads to SIGABRT and prints ``` ARRAY = my_directory/file1my_directory/file2my_directory/dum1 my_directory/dum2 corrupted size vs. prev_size ``` I have tested with gfortran 13.2.1 (gfortran -o test program.f90), on Fedora 38. It should also be noticed that both function calls run fine if we remove the `trim(prefix)//` from each character string. ``` program test implicit none character(len=256) :: test_array(4) character(len=:), allocatable :: prefix integer :: res prefix = 'my_directory' test_array = [ character(len=256) :: & & trim(prefix)//'/file1', & & trim(prefix)//'/file2', & & trim(prefix)//'/dum1', & & trim(prefix)//'/dum2' & & ] print *, 'Test with "res = func1(test_array)"' res = func1(test_array) print *, 'Test with "res = func1([ character(len=) :: ...] )"' res = func1([ character(len=256) :: & & trim(prefix)//'/file1', & & trim(prefix)//'/file2', & & trim(prefix)//'/dum1', & & trim(prefix)//'/dum2' & & ]) contains function func1(array) result(res) character(len=*), intent(in) :: array(:) integer :: res print *, 'ARRAY = ', array res = 0 end function func1 end program test ```