This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/33254] Diagnose different string lengths in array constructors at run time
- From: "dominiq at lps dot ens dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Oct 2007 09:38:11 -0000
- Subject: [Bug fortran/33254] Diagnose different string lengths in array constructors at run time
- References: <bug-33254-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from dominiq at lps dot ens dot fr 2007-10-11 09:38 -------
After applying the patch and the one to PR33727 (thanks Paul!-), the first test
fails at runtime:
At line 6 of file pr32703_1.f90
Fortran runtime error: Different CHARACTER lengths (1/2) in array constructor
but the following code
program array_char
implicit none
character (len=2) :: x, y
character (len=2) :: z(2)
x = "a "
y = "cd"
z = (/y(1:len(trim(y))), x(1:len(trim(x)))/) ! causes segfault
print *, "'", z(1), "' '", z(2), "'"
end program array_char
gives
[karma] f90/bug% gfc -fbounds-check pr33727_bad.f90
[karma] f90/bug% a.out
'cd' 'a'
I am expecting this test to fail at runtime and the other one. Am I missing
something.
I have also noticed something strange with the following valid(?) code:
program array_char
implicit none
character (len=2) :: x, y
character (len=2) :: z(2)
x = "a "
y = "cd"
z = " "
z = (/y(1:len(trim(x))), x(1:len(trim(x)))/)
print *, "'", z(1), "' '", z(2), "'"
end program array_char
which gives
'c' 'a'
while I am expecting
'c ' 'a '
Looks like another bug, should I fill a new PR?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33254