* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
@ 2007-12-08 23:03 ` burnus at gcc dot gnu dot org
2007-12-08 23:08 ` dominiq at lps dot ens dot fr
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-12-08 23:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2007-12-08 23:02 -------
According to NAG f95 the program is invalid; it prints at run time:
Unequal character lengths (1 and 2) in array constructor
Program terminated by fatal error
In ARRAY_CHAR, line 9 of aaa.f90
I actually would expect gfortran to diagnose this with -fbounds-check.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
2007-12-08 23:03 ` [Bug fortran/34396] " burnus at gcc dot gnu dot org
@ 2007-12-08 23:08 ` dominiq at lps dot ens dot fr
2007-12-09 6:20 ` jv244 at cam dot ac dot uk
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-12-08 23:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from dominiq at lps dot ens dot fr 2007-12-08 23:08 -------
> I actually would expect gfortran to diagnose this with -fbounds-check.
Me too, but this works only if the lengths are correctly computed. The test
case pass the bounds check.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
2007-12-08 23:03 ` [Bug fortran/34396] " burnus at gcc dot gnu dot org
2007-12-08 23:08 ` dominiq at lps dot ens dot fr
@ 2007-12-09 6:20 ` jv244 at cam dot ac dot uk
2007-12-09 6:20 ` jv244 at cam dot ac dot uk
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-12-09 6:20 UTC (permalink / raw)
To: gcc-bugs
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-12-09 06:20:24
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (2 preceding siblings ...)
2007-12-09 6:20 ` jv244 at cam dot ac dot uk
@ 2007-12-09 6:20 ` jv244 at cam dot ac dot uk
2007-12-09 9:29 ` pault at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-12-09 6:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from jv244 at cam dot ac dot uk 2007-12-09 06:20 -------
changing into:
z = (/y(1:len(trim(y))), x(1:len(trim(x)))//"e"/)
makes this valid and shows the same issue on valid code
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |32834
nThis| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (3 preceding siblings ...)
2007-12-09 6:20 ` jv244 at cam dot ac dot uk
@ 2007-12-09 9:29 ` pault at gcc dot gnu dot org
2007-12-09 9:35 ` dominiq at lps dot ens dot fr
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-09 9:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pault at gcc dot gnu dot org 2007-12-09 09:29 -------
For the original, I am getting:
|cd| |a|
99 100 0 0 0
97 0 0 0 0
and for comment #3:
|cd| |ae|
99 100 0 0 0
97 101 0 0 0
Today's trunk on x86_ia64/fc5.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (4 preceding siblings ...)
2007-12-09 9:29 ` pault at gcc dot gnu dot org
@ 2007-12-09 9:35 ` dominiq at lps dot ens dot fr
2007-12-09 17:14 ` pault at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-12-09 9:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from dominiq at lps dot ens dot fr 2007-12-09 09:34 -------
> For the original, I am getting: ...
Yes it depends of the memory content, anyway the 0 in your results should be
spaces.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (5 preceding siblings ...)
2007-12-09 9:35 ` dominiq at lps dot ens dot fr
@ 2007-12-09 17:14 ` pault at gcc dot gnu dot org
2007-12-16 11:45 ` pault at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-09 17:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pault at gcc dot gnu dot org 2007-12-09 17:14 -------
Dominique,
> Yes it depends of the memory content, anyway the 0 in your results should be
> spaces.
>
Ah yes. The problem is in trans-array.c(gfc_trans_array_ctor_element), where
the assignment, line 975 onwards, uses memcpy and produces this code:
{
integer(kind=4) D.879;
integer(kind=4) len.6;
character(kind=1) * pstr.5;
_gfortran_string_trim (&len.6, (void * *) &pstr.5, 5, &y[1]{lb: 1 sz:
1});
D.879 = len.6;
if (len.6 > 0)
{
{
void * D.878;
D.878 = (void *) pstr.5;
if (D.878 != 0B)
{
__builtin_free (D.878);
}
}
}
__builtin_memcpy (&(*(character(kind=1)[0:][1:5] *)
atmp.2.data)[0][1]{lb: 1 sz: 1}, &y[1]{lb: 1 sz: 1}, MAX_EXPR <NON_LVALUE_EXPR
<D.879>, 0>);
}
This is called in two places and the returned se->string_length could be used
for bounds checking. Also, the required padding with spaces could be done too.
ss->string_length has the length of the target.
I am setting aside evenings of this week to a determined attack on PRs 31213,
33888 and 33998. I have solutions to most of the bugs and it now needs
packaging up and submitting. If this PR still remains next week, I'll give it a
try. Otherwise, I would be happy to lend a helping hand...
Cheers
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (6 preceding siblings ...)
2007-12-09 17:14 ` pault at gcc dot gnu dot org
@ 2007-12-16 11:45 ` pault at gcc dot gnu dot org
2008-01-10 14:29 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-12-16 11:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2007-12-16 11:45 -------
OK then, I'll give it a try!
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-12-09 06:20:24 |2007-12-16 11:45:31
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (7 preceding siblings ...)
2007-12-16 11:45 ` pault at gcc dot gnu dot org
@ 2008-01-10 14:29 ` burnus at gcc dot gnu dot org
2008-01-10 19:25 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-10 14:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from burnus at gcc dot gnu dot org 2008-01-10 07:45 -------
Patch: http://gcc.gnu.org/ml/fortran/2008-01/msg00117.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (8 preceding siblings ...)
2008-01-10 14:29 ` burnus at gcc dot gnu dot org
@ 2008-01-10 19:25 ` pault at gcc dot gnu dot org
2008-01-10 19:25 ` pault at gcc dot gnu dot org
2008-06-17 18:10 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-10 19:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pault at gcc dot gnu dot org 2008-01-10 19:11 -------
Subject: Bug 34396
Author: pault
Date: Thu Jan 10 19:10:48 2008
New Revision: 131448
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131448
Log:
2008-01-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34396
* trans-array.c (gfc_trans_array_ctor_element): Use
gfc_trans_string_copy
to assign strings and perform bounds checks on the string length.
(get_array_ctor_strlen): Remove bounds checking.
(gfc_trans_array_constructor): Initialize string length checking.
* trans-array.h : Add prototype for gfc_trans_string_copy.
2008-01-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34396
* gfortran.dg/bounds_check_12.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/bounds_check_12.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-array.h
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (9 preceding siblings ...)
2008-01-10 19:25 ` pault at gcc dot gnu dot org
@ 2008-01-10 19:25 ` pault at gcc dot gnu dot org
2008-06-17 18:10 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-10 19:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from pault at gcc dot gnu dot org 2008-01-10 19:13 -------
Fixed on trunk
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/34396] Length of substrings defined by expressions not correctly computed in constructors
2007-12-08 21:02 [Bug fortran/34396] New: Length of substrings defined by expressions not correctly computed in constructors dominiq at lps dot ens dot fr
` (10 preceding siblings ...)
2008-01-10 19:25 ` pault at gcc dot gnu dot org
@ 2008-06-17 18:10 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-06-17 18:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pault at gcc dot gnu dot org 2008-06-17 18:09 -------
Subject: Bug 34396
Author: pault
Date: Tue Jun 17 18:08:24 2008
New Revision: 136871
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136871
Log:
2008-06-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34396
* resolve.c (add_dt_to_dt_list): New function.
(resolve_fl_derived): Call new function for pointer components
and when derived type resolved.
2008-06-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36366
* gfortran.dg/used_types_20.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/used_types_20.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34396
^ permalink raw reply [flat|nested] 13+ messages in thread