public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34546]  New: Incorrect array identified in out of bounds runtime error
@ 2007-12-21  8:35 terry at chem dot gu dot se
  2007-12-21 10:11 ` [Bug fortran/34546] " dfranke at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: terry at chem dot gu dot se @ 2007-12-21  8:35 UTC (permalink / raw)
  To: gcc-bugs

I think this one's a bit bizarre.  (But then again, which bugs aren't?  ;-)


$ cat is
isotope*      isotope.f90   
[tjf@fkpc167 Bug9]$ cat isotope.f90 
program fred
implicit none
integer,parameter::NoJmax=6000
integer,parameter::MaxTotalJ=100
integer,parameter::ER=14513
real,parameter::EnergyFactor=1.5
real(kind=8),dimension(ER:nint(EnergyFactor*ER),6)::pT
real(kind=8),dimension(0:MaxTotalJ,0:NoJmax,6)::JTEJ
integer::JJ,E

JTEJ=1
pT=2

write(*,*)ER

JJ=0
E=2000

write(*,*)size(JTEJ(JJ,E,:))
write(*,*)size(pT(E,:))

write(10,*)JJ,E,real(JTEJ(JJ,E,:))
write(10,*)JJ,E,real(JTEJ(JJ,E,:)*pT(E,:))

end

$ gfortran --version
GNU Fortran (GCC) 4.3.0 20071109 (experimental)
Copyright (C) 2007 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING

$ gfortran -Wall -W -Wtabs -g -fbounds-check -O -o isotope isotope.f90
$ ./isotope 
       14513
           6
           6
At line 23 of file isotope.f90
Fortran runtime error: Array reference out of bounds for array 'jtej', lower
bound of dimension 1 exceeded(2000 < 14513)


Yes, it's bad code.  But what's with the bounds of pT being projected onto
JTEJ?

(Of course, apologies if it's been fixed since November!)


-- 
           Summary: Incorrect array identified in out of bounds runtime
                    error
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: terry at chem dot gu dot se
  GCC host triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
@ 2007-12-21 10:11 ` dfranke at gcc dot gnu dot org
  2008-07-02  2:11 ` terry at chem dot gu dot se
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-12-21 10:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dfranke at gcc dot gnu dot org  2007-12-21 10:10 -------
Confirmed. 

Reduced testcase:

$> cat pr34546.f90
program fred
implicit none
real :: JTEJ(0:100,0:6000,6) = 1.0
real :: pT(10000:20000, 6)   = 2.0

write(*,*) JTEJ(0,1000,:) * pT(1000,:)
end

$> fortran-svn -g -Wall -fbounds-check pr34546.f90 && ./a.out
At line 6 of file pr34546.f90
Fortran runtime error: Array reference out of bounds for array 'jtej', lower
bound of dimension 1 exceeded(1000 < 10000)


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dfranke at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   GCC host triplet|x86_64-unknown-linux-gnu    |
      Known to fail|                            |4.3.0
   Last reconfirmed|0000-00-00 00:00:00         |2007-12-21 10:10:48
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
  2007-12-21 10:11 ` [Bug fortran/34546] " dfranke at gcc dot gnu dot org
@ 2008-07-02  2:11 ` terry at chem dot gu dot se
  2008-07-02  5:07 ` jvdelisle at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: terry at chem dot gu dot se @ 2008-07-02  2:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from terry at chem dot gu dot se  2008-07-02 02:10 -------
A gentle reminder:  This problem still exists as of 4.3.2 20080626.

(At least a compile-time warning is generated for Daniel's testcase.  If that
1000 index is an integer variable, however, the compile-time warning goes away
and the bounds check still indicates the wrong array.)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
  2007-12-21 10:11 ` [Bug fortran/34546] " dfranke at gcc dot gnu dot org
  2008-07-02  2:11 ` terry at chem dot gu dot se
@ 2008-07-02  5:07 ` jvdelisle at gcc dot gnu dot org
  2008-07-02  5:12 ` terry at chem dot gu dot se
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-07-02  5:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2008-07-02 05:06 -------
Currently 4.4 is giving:

$ gfc bounds.f90 
bounds.f90:6.31:

write(*,*) JTEJ(0,1000,:) * pT(1000,:)
                              1
Warning: Array reference at (1) is out of bounds (1000 < 10000) in dimension 1

I am not sure which patch did this, but I doubt it will be backported to 4.3


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
                   ` (2 preceding siblings ...)
  2008-07-02  5:07 ` jvdelisle at gcc dot gnu dot org
@ 2008-07-02  5:12 ` terry at chem dot gu dot se
  2009-03-29  7:44 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: terry at chem dot gu dot se @ 2008-07-02  5:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from terry at chem dot gu dot se  2008-07-02 05:11 -------
(In reply to comment #3)
> I am not sure which patch did this, but I doubt it will be backported to 4.3


It already is in 4.3.  ;-)  As I said earlier, that warning is produced, but
easy to make go away with

integer::n ... n=1000 ... pT(n,:)

at the appropriate places.  Mangled runtime error message remains.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
                   ` (3 preceding siblings ...)
  2008-07-02  5:12 ` terry at chem dot gu dot se
@ 2009-03-29  7:44 ` fxcoudert at gcc dot gnu dot org
  2009-12-11 22:20 ` dfranke at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-03-29  7:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2009-03-29 07:44 -------
Wrong runtime error message is still there:

$ cat a.f90 
  real :: u(1,1) = 1.0
  real :: v(1, 1) = 2.0
  write(*,*) u(1,:) * v(2,:)
  end
$ gfortran a.f90 -fbounds-check -w && ./a.out
At line 3 of file a.f90
Fortran runtime error: Array reference out of bounds for array 'u', upper bound
of dimension 1  exceeded (2 > 1)


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
      Known to fail|4.3.0                       |4.3.0 4.4.0 4.5.0
   Last reconfirmed|2007-12-21 10:10:48         |2009-03-29 07:44:10
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
                   ` (4 preceding siblings ...)
  2009-03-29  7:44 ` fxcoudert at gcc dot gnu dot org
@ 2009-12-11 22:20 ` dfranke at gcc dot gnu dot org
  2010-04-16 16:39 ` kargl at gcc dot gnu dot org
  2010-04-16 16:39 ` kargl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-12-11 22:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dfranke at gcc dot gnu dot org  2009-12-11 22:20 -------
For the example in #1, the wrong name is picked up in trans-array.c
(gfc_trans_array_bound_check):

2310  if (!name && se->loop && se->loop->ss && se->loop->ss->expr
2311      && se->loop->ss->expr->symtree)
2312    name = se->loop->ss->expr->symtree->name;

No idea where to look for the correct one.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
                   ` (5 preceding siblings ...)
  2009-12-11 22:20 ` dfranke at gcc dot gnu dot org
@ 2010-04-16 16:39 ` kargl at gcc dot gnu dot org
  2010-04-16 16:39 ` kargl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 16:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from kargl at gcc dot gnu dot org  2010-04-16 16:38 -------
Taking the code in comment #1, and changing the initialization to
an assignment.

program fred
implicit none
real :: JTEJ(0:100,0:6000,6) 
real :: pT(10000:20000, 6)
JTEJ = 1.0
pT   = 2.0
write(*,*) JTEJ(0,1000,:) * pT(1000,:)
end

I get
laptop:kargl[269] gfc4x -o z -fcheck=bounds g.f90 -fdump-tree-original
g.f90:7.31:

write(*,*) JTEJ(0,1000,:) * pT(1000,:)
                               1
Warning: Array reference at (1) is out of bounds (1000 < 10000) in dimension 1
laptop:kargl[270] ./z
At line 7 of file g.f90
Fortran runtime error: Index '1000' of dimension 1 of array 'pt' outside of
expected range (10000:20000)

First, the warning should be sufficient to tell the programmer that
there is a problem.  Second, the runtime error message is correct.

For the code in comment #6, we have

laptop:kargl[272] gfc4x -o z -fcheck=bounds g.f90 
g.f90:3.24:

  write(*,*) u(1,:) * v(2,:)
                        1
Warning: Array reference at (1) is out of bounds (2 > 1) in dimension 1
laptop:kargl[273] ./z
At line 3 of file g.f90

Fortran runtime error: Index '2' of dimension 1 of array 'v' outside of
expected range (1:1)

Thus, I'm closing this as fixed.


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/34546] Incorrect array identified in out of bounds runtime error
  2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
                   ` (6 preceding siblings ...)
  2010-04-16 16:39 ` kargl at gcc dot gnu dot org
@ 2010-04-16 16:39 ` kargl at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: kargl at gcc dot gnu dot org @ 2010-04-16 16:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from kargl at gcc dot gnu dot org  2010-04-16 16:39 -------
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=34546


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-04-16 16:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-21  8:35 [Bug fortran/34546] New: Incorrect array identified in out of bounds runtime error terry at chem dot gu dot se
2007-12-21 10:11 ` [Bug fortran/34546] " dfranke at gcc dot gnu dot org
2008-07-02  2:11 ` terry at chem dot gu dot se
2008-07-02  5:07 ` jvdelisle at gcc dot gnu dot org
2008-07-02  5:12 ` terry at chem dot gu dot se
2009-03-29  7:44 ` fxcoudert at gcc dot gnu dot org
2009-12-11 22:20 ` dfranke at gcc dot gnu dot org
2010-04-16 16:39 ` kargl at gcc dot gnu dot org
2010-04-16 16:39 ` kargl at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).