* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
@ 2006-12-05 14:30 ` burnus at gcc dot gnu dot org
2007-01-22 21:32 ` fxcoudert at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2006-12-05 14:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2006-12-05 14:30 -------
Shorter test:
real :: a(1,1), b(3)
integer :: i
b = 45.0
i = 2
a(1,1:i) = b(i)
end
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
2006-12-05 14:30 ` [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array burnus at gcc dot gnu dot org
@ 2007-01-22 21:32 ` fxcoudert at gcc dot gnu dot org
2010-04-15 16:11 ` kargl at gcc dot gnu dot org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-01-22 21:32 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-01-22 21:32:30
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
2006-12-05 14:30 ` [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array burnus at gcc dot gnu dot org
2007-01-22 21:32 ` fxcoudert at gcc dot gnu dot org
@ 2010-04-15 16:11 ` kargl at gcc dot gnu dot org
2010-04-15 16:28 ` kargl at gcc dot gnu dot org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-15 16:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from kargl at gcc dot gnu dot org 2010-04-15 16:10 -------
(In reply to comment #1)
> Shorter test:
>
> real :: a(1,1), b(3)
> integer :: i
> b = 45.0
> i = 2
> a(1,1:i) = b(i)
> end
Gfortran seems to do the right thing on this test case.
laptop:kargl[212] gfc4x -o z -fcheck=all a.f90 -fdump-tree-original
laptop:kargl[213] ./z
At line 5 of file a.f90
Fortran runtime error: Index '2' of dimension 2 of array 'a' outside
of expected range (1:1)
The original testcase in comment #1 still contains the variable.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2010-04-15 16:11 ` kargl at gcc dot gnu dot org
@ 2010-04-15 16:28 ` kargl at gcc dot gnu dot org
2010-04-15 19:55 ` kargl at gcc dot gnu dot org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-15 16:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from kargl at gcc dot gnu dot org 2010-04-15 16:28 -------
Looking at the -ftree-dump-original output for the code
in comment #1 finds,
if ((logical(kind=4)) __builtin_expect (a.dim[1].ubound < D.1545, 0))
{
_gfortran_runtime_error_at (&"At line 11 of file a.f90"[1]{lb:1 sz:1},
&"Index \'%ld\' of dimension 2 of array \'t\' outside of expected
range (%ld:%ld)"[1]{lb: 1 sz: 1}, (<unnamed-signed:32>) D.1545,
(<unnamed-signed:32>) a.dim[1].lbound, (<unnamed-signed:32>)
a.dim[1].ubound);
}
which shows the correct bounds for 'a' are being checked, but
the wrong variable name 't' is inserted in error message. Note,
this code fragment occurs during the actual act of assignment.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2010-04-15 16:28 ` kargl at gcc dot gnu dot org
@ 2010-04-15 19:55 ` kargl at gcc dot gnu dot org
2010-04-15 21:32 ` kargl at gcc dot gnu dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-15 19:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from kargl at gcc dot gnu dot org 2010-04-15 19:55 -------
(In reply to comment #3)
> Looking at the -ftree-dump-original output for the code
> in comment #1 finds,
>
> if ((logical(kind=4)) __builtin_expect (a.dim[1].ubound < D.1545, 0))
> {
> _gfortran_runtime_error_at (&"At line 11 of file a.f90"[1]{lb:1 sz:1},
> &"Index \'%ld\' of dimension 2 of array \'t\' outside of expected
> range (%ld:%ld)"[1]{lb: 1 sz: 1}, (<unnamed-signed:32>) D.1545,
> (<unnamed-signed:32>) a.dim[1].lbound, (<unnamed-signed:32>)
> a.dim[1].ubound);
> }
>
> which shows the correct bounds for 'a' are being checked, but
> the wrong variable name 't' is inserted in error message. Note,
> this code fragment occurs during the actual act of assignment.
>
The problem is in trans-array.c(gfc_trans_array_bound_check).
The two blocks of code
if (!name && se->loop && se->loop->ss && se->loop->ss->expr
&& se->loop->ss->expr->symtree)
name = se->loop->ss->expr->symtree->name;
if (!name && se->loop && se->loop->ss && se->loop->ss->loop_chain
&& se->loop->ss->loop_chain->expr
&& se->loop->ss->loop_chain->expr->symtree)
name = se->loop->ss->loop_chain->expr->symtree->name;
are meant to set 'name' to the relevant variable. The first
sets 'name' to point at 't' while the second block would set
'name' to point at 'a'. Clearly, the 2nd 'if ()' fails because
'name' is non-null.
If we look further down, we see
/* If upper bound is present, include both bounds in the error message. */
if (check_upper)
{
tmp_lo = gfc_conv_array_lbound (descriptor, n);
tmp_up = gfc_conv_array_ubound (descriptor, n);
if (name)
asprintf (&msg, "Index '%%ld' of dimension %d of array '%s' "
"outside of expected RANGE (%%ld:%%ld)", n+1, name);
What we need is a way to take 'descriptor' and find the name of
the entity it is associated with.
tobias and I worked out a possible fix on IRC.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (4 preceding siblings ...)
2010-04-15 19:55 ` kargl at gcc dot gnu dot org
@ 2010-04-15 21:32 ` kargl at gcc dot gnu dot org
2010-04-15 21:44 ` kargl at gcc dot gnu dot org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-15 21:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from kargl at gcc dot gnu dot org 2010-04-15 21:32 -------
Subject: Bug 30073
Author: kargl
Date: Thu Apr 15 21:32:21 2010
New Revision: 158392
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158392
Log:
PR fortran/30073
* trans-array.c (gfc_trans_array_bound_check): Eliminate a redundant
block of code. Set name to the variable associated with the descriptor.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (5 preceding siblings ...)
2010-04-15 21:32 ` kargl at gcc dot gnu dot org
@ 2010-04-15 21:44 ` kargl at gcc dot gnu dot org
2010-04-16 15:49 ` kargl at gcc dot gnu dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-15 21:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from kargl at gcc dot gnu dot org 2010-04-15 21:44 -------
Fixed on trunk. I'll backport the patch to 4.4 and 4.5 soon.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |kargl at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-01-22 21:32:30 |2010-04-15 21:44:28
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (6 preceding siblings ...)
2010-04-15 21:44 ` kargl at gcc dot gnu dot org
@ 2010-04-16 15:49 ` kargl at gcc dot gnu dot org
2010-04-16 15:50 ` kargl at gcc dot gnu dot org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 15:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from kargl at gcc dot gnu dot org 2010-04-16 15:49 -------
Subject: Bug 30073
Author: kargl
Date: Fri Apr 16 15:48:40 2010
New Revision: 158431
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158431
Log:
2010-04-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30073
* trans-array.c (gfc_trans_array_bound_check): Eliminate a redundant
block of code. Set name to the variable associated with the descriptor.
Modified:
branches/gcc-4_4-branch/gcc/fortran/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (7 preceding siblings ...)
2010-04-16 15:49 ` kargl at gcc dot gnu dot org
@ 2010-04-16 15:50 ` kargl at gcc dot gnu dot org
2010-04-16 15:53 ` kargl at gcc dot gnu dot org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 15:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from kargl at gcc dot gnu dot org 2010-04-16 15:49 -------
Backported to 4.5. Patch does not apply cleanly
to 4.4. Closing as FIXED.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (8 preceding siblings ...)
2010-04-16 15:50 ` kargl at gcc dot gnu dot org
@ 2010-04-16 15:53 ` kargl at gcc dot gnu dot org
2010-04-16 15:56 ` kargl at gcc dot gnu dot org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 15:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from kargl at gcc dot gnu dot org 2010-04-16 15:53 -------
Subject: Bug 30073
Author: kargl
Date: Fri Apr 16 15:53:04 2010
New Revision: 158432
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158432
Log:
2010-04-16 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30073
* trans-array.c (gfc_trans_array_bound_check): Eliminate a redundant
block of code. Set name to the variable associated with the descriptor.
Modified:
branches/gcc-4_5-branch/gcc/fortran/ChangeLog
branches/gcc-4_5-branch/gcc/fortran/trans-array.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (9 preceding siblings ...)
2010-04-16 15:53 ` kargl at gcc dot gnu dot org
@ 2010-04-16 15:56 ` kargl at gcc dot gnu dot org
2010-04-16 16:36 ` kargl at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 15:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from kargl at gcc dot gnu dot org 2010-04-16 15:55 -------
(In reply to comment #7)
> Subject: Bug 30073
>
> Author: kargl
> Date: Fri Apr 16 15:48:40 2010
> New Revision: 158431
>
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158431
> Log:
> 2010-04-16 Steven G. Kargl <kargl@gcc.gnu.org>
>
> PR fortran/30073
> * trans-array.c (gfc_trans_array_bound_check): Eliminate a redundant
> block of code. Set name to the variable associated with the descriptor.
>
> Modified:
> branches/gcc-4_4-branch/gcc/fortran/ChangeLog
>
Argh.. I was in the wrong branch when I try to do
the 4.5 commit. I've remoed the erronous ChangeLog
entry.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (10 preceding siblings ...)
2010-04-16 15:56 ` kargl at gcc dot gnu dot org
@ 2010-04-16 16:36 ` kargl at gcc dot gnu dot org
2010-04-24 20:32 ` kargl at gcc dot gnu dot org
2010-04-24 21:47 ` kargl at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 16:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from kargl at gcc dot gnu dot org 2010-04-16 16:35 -------
Set target milestone.
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.5.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (11 preceding siblings ...)
2010-04-16 16:36 ` kargl at gcc dot gnu dot org
@ 2010-04-24 20:32 ` kargl at gcc dot gnu dot org
2010-04-24 21:47 ` kargl at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-24 20:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from kargl at gcc dot gnu dot org 2010-04-24 20:32 -------
Subject: Bug 30073
Author: kargl
Date: Sat Apr 24 20:32:04 2010
New Revision: 158692
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158692
Log:
2010-04-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30073
PR fortran/43793
* trans-array.c (gfc_trans_array_bound_check): Use TREE_CODE instead
of mucking with a tree directly.
2010-04-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30073
PR fortran/43793
gfortran.dg/pr43793.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/pr43793.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug fortran/30073] Array out of bounds gives name of RHS array not LHS array
2006-12-05 14:06 [Bug fortran/30073] New: Array out of bounds gives name of LHS array not RHS burnus at gcc dot gnu dot org
` (12 preceding siblings ...)
2010-04-24 20:32 ` kargl at gcc dot gnu dot org
@ 2010-04-24 21:47 ` kargl at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-24 21:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from kargl at gcc dot gnu dot org 2010-04-24 21:47 -------
Subject: Bug 30073
Author: kargl
Date: Sat Apr 24 21:46:45 2010
New Revision: 158693
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158693
Log:
010-04-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30073
PR fortran/43793
* trans-array.c (gfc_trans_array_bound_check): Use TREE_CODE instead
of mucking with a tree directly.
2010-04-24 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/30073
PR fortran/43793
gfortran.dg/pr43793.f90: New test.
Added:
branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/pr43793.f90
Modified:
branches/gcc-4_5-branch/gcc/fortran/ChangeLog
branches/gcc-4_5-branch/gcc/fortran/trans-array.c
branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30073
^ permalink raw reply [flat|nested] 15+ messages in thread