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: "tobi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Oct 2007 21:18:48 -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 #16 from tobi at gcc dot gnu dot org 2007-10-21 21:18 -------
Re this testcase:
(In reply to comment #5)
> 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
Changing z's length to, say, 5 shows that the strings are correctly padded,
i.e. z(1) == "cd " after the assignment, so there's only an issue with
bounds-checking not working on this code, it doesn't expose another bug. I've
yet to figure out how to evaluate the string length, and only evaluate it once.
Dominique has correctly identified one of the crucial parts of the code in
#14. I hope I can look at this tomorrow night or Wednesday night.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33254