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: "Tobias dot Schlueter at physik dot uni-muenchen dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Oct 2007 10:45:46 -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 #6 from Tobias dot Schlueter at physik dot uni-muenchen dot de 2007-10-11 10:45 -------
Subject: Re: Diagnose different string lengths in array
constructors at run time
dominiq at lps dot ens dot fr wrote:
> 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.
This is weird, and can't really be (well, in a hypothetical world where
only the bounds check goes wrong), as the whole array has only a single
string length, so I would expect it to either print two length one
strings or two length two strings, not one lenghth one string and one
length two string.
>
> 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?
Yes. This looks related to the previous one, again the string length
seems to be taken from the wrong place.
Are these with or without Paul's patch?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33254