This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/53296] Segfault on non-constant character array constructor containing kind spec
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 10 May 2012 10:35:22 +0000
- Subject: [Bug fortran/53296] Segfault on non-constant character array constructor containing kind spec
- Auto-submitted: auto-generated
- References: <bug-53296-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53296
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-10 10:35:22 UTC ---
Simplified program.
* As is, it prints 128
* Without "txt", it prints 5 and segfaults
* Without character(len=128) :: "txt", it prints 5 and works
Thus, the extension to 128 characters does not properly work in the case of
having no character literal. That matches what is in the code:
character(kind=1) A.16[2][1:5];
vs.
character(kind=1) A.15[3][1:128];
I have not looked through the source code, but the first place, where
constructors string lengths are handled is array.c's
gfc_resolve_character_array_constructor. I don't quickly see whether it does so
correctly or not. If it does, the failure must be later.
It might be that in that function, the "txt" is correctly extended and padded
to len=128 - and that then everything is later handled correctly because the
first element has the right size?
program charArrErr
implicit none
call rou([character(len=128) :: "txt", uCase("abcde"),uCase("ghij_")])
contains
subroutine rou(arr)
implicit none
character(*),intent(in) :: arr(:)
print *, len(arr)
end subroutine
function uCase(str)
implicit none
character(*), intent(in) :: str
character(len(str)) :: uCase
uCase=str
end function uCase
end program charArrErr