Bug 27766 (Fortran_bounds_checking) - [meta-bug] -fbounds-check related bugs
Summary: [meta-bug] -fbounds-check related bugs
Status: NEW
Alias: Fortran_bounds_checking
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: meta-bug
Depends on: 31059 34740 36683 39772 44744 45057 45425 77649 81095 82243 82660 83953 86033 90795 111339 19777 24401 26801 27524 27588 27765 27786 27874 27965 27989 28129 28849 29572 29677 29800 29804 30073 30402 30655 30802 30814 30939 31119 31278 31538 31627 31822 32036 32315 32317 32454 32890 33254 33745 34159 34546 34670 34741 35732 35943 36029 36112 36341 36670 36754 37746 37802 38235 39195 39286 39872 39994 40383 52162 52788 60370 71706 85631 86100
Blocks:
  Show dependency treegraph
 
Reported: 2006-05-24 21:46 UTC by Francois-Xavier Coudert
Modified: 2023-09-08 09:29 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-24 21:51:10


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois-Xavier Coudert 2006-05-24 21:46:12 UTC
This PR is opened for tracking all bugs related to the -fbounds-check option.
Comment 1 Francois-Xavier Coudert 2006-05-24 21:51:10 UTC
With gfortran mainline 20060517 (and the patch for PR 27524), here is a list of failures recorder when the testsuite is run with -fbounds-check (command line is make check-gfortran RUNTESTFLAGS="-target_board=unix/-fbounds-check"):

gfortran.dg/aliasing_dummy_1.f90
gfortran.dg/cray_pointers_2.f90
gfortran.dg/pr15140.f90
gfortran.dg/pr25603.f
gfortran.dg/g77/dnrm2.f
gfortran.dg/gomp/appendix-a/a.12.1.f90
gfortran.dg/gomp/appendix-a/a.30.1.f90
gfortran.dg/gomp/appendix-a/a.31.1.f90
gfortran.dg/gomp/appendix-a/a.31.2.f90
gfortran.dg/gomp/appendix-a/a.8.1.f90
gfortran.fortran-torture/execute/assumed_size.f90
gfortran.fortran-torture/execute/forall_3.f90
gfortran.fortran-torture/execute/where_7.f90
gfortran.fortran-torture/execute/where_8.f90
Comment 2 Francois-Xavier Coudert 2006-05-27 09:03:52 UTC
(In reply to comment #1)
> make check-gfortran RUNTESTFLAGS="-target_board=unix/-fbounds-check"

With mainline today and the patch for PR 19777, the list is failure is now:

gfortran.dg/cray_pointers_2.f90
gfortran.dg/pr15140.f90
gfortran.dg/g77/dnrm2.f
gfortran.fortran-torture/execute/assumed_size.f90
gfortran.fortran-torture/execute/forall_3.f90
gfortran.fortran-torture/execute/where_7.f90
gfortran.fortran-torture/execute/where_8.f90
Comment 3 Thomas Koenig 2008-04-30 20:02:43 UTC
Failures at the moment:

FAIL: gfortran.dg/array_memset_2.f90  -O0  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O1  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O2  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -fomit-frame-pointer  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -fomit-frame-pointer -funroll-loops  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -g  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -Os  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/forall_13.f90  -O0  execution test
FAIL: gfortran.dg/forall_13.f90  -O1  execution test
FAIL: gfortran.dg/forall_13.f90  -O2  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer -funroll-loops  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -g  execution test
FAIL: gfortran.dg/forall_13.f90  -Os  execution test
FAIL: gfortran.dg/ltrans-7.f90  -O  scan-tree-dump-times ltrans "transformed loop" 1
FAIL: gfortran.dg/g77/dnrm2.f  -O0  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O1  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O2  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -fomit-frame-pointer -funroll-loops  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -Os  execution test
Running /home/ig25/gcc/trunk/gcc/testsuite/gfortran.dg/gomp/gomp.exp ...
Running /home/ig25/gcc/trunk/gcc/testsuite/gfortran.dg/vect/vect.exp ...
FAIL: gfortran.dg/vect/vect-3.f90  -O  scan-tree-dump-times vect "Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-3.f90  -O  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "vectorized 1 loops" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/pr19049.f90  -O  scan-tree-dump-times vect "complicated access pattern" 1
Comment 4 Thomas Koenig 2008-04-30 20:47:49 UTC
(In reply to comment #3)

> FAIL: gfortran.dg/array_memset_2.f90  -O0  scan-tree-dump-times original  "memset" 2

This is due to a false positive because "memset" in the error message
(due to the filename) matches more than two times.
Comment 5 Thomas Koenig 2008-11-22 23:52:42 UTC
Current failures with bounds checking:

FAIL: gfortran.dg/array_memset_2.f90  -O0  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O1  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O2  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -fomit-frame-pointer  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -fomit-frame-pointer -funroll-loops  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -O3 -g  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/array_memset_2.f90  -Os  scan-tree-dump-times original "memset" 2
FAIL: gfortran.dg/bound_2.f90  -O0  execution test
FAIL: gfortran.dg/bound_2.f90  -O1  execution test
FAIL: gfortran.dg/bound_2.f90  -O2  execution test
FAIL: gfortran.dg/bound_2.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/bound_2.f90  -O3 -fomit-frame-pointer -funroll-loops  execution test
FAIL: gfortran.dg/bound_2.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/bound_2.f90  -O3 -g  execution test
FAIL: gfortran.dg/bound_2.f90  -Os  execution test
FAIL: gfortran.dg/forall_13.f90  -O0  execution test
FAIL: gfortran.dg/forall_13.f90  -O1  execution test
FAIL: gfortran.dg/forall_13.f90  -O2  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer -funroll-loops  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -g  execution test
FAIL: gfortran.dg/forall_13.f90  -Os  execution test
FAIL: gfortran.dg/ldist-1.f90  -O  scan-tree-dump-times ldist "distributed: split to 4 loops" 1
FAIL: gfortran.dg/ltrans-7.f90  -O  scan-tree-dump-times ltrans "transformed loop" 1
FAIL: gfortran.dg/pr37243.f  -O0  execution test
FAIL: gfortran.dg/pr37243.f  -O1  execution test
FAIL: gfortran.dg/pr37243.f  -O2  execution test
FAIL: gfortran.dg/pr37243.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/pr37243.f  -O3 -fomit-frame-pointer -funroll-loops  execution test
FAIL: gfortran.dg/pr37243.f  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/pr37243.f  -O3 -g  execution test
FAIL: gfortran.dg/pr37243.f  -Os  execution test
FAIL: gfortran.dg/reassoc_4.f  -O  scan-tree-dump-times reassoc1 "[0-9] \* " 22
FAIL: gfortran.dg/g77/dnrm2.f  -O0  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O1  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O2  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -fomit-frame-pointer -funroll-loops  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -O3 -g  execution test
FAIL: gfortran.dg/g77/dnrm2.f  -Os  execution test
Running /home/ig25/gcc/trunk/gcc/testsuite/gfortran.dg/gomp/gomp.exp ...
Running /home/ig25/gcc/trunk/gcc/testsuite/gfortran.dg/graphite/graphite.exp ...
Running /home/ig25/gcc/trunk/gcc/testsuite/gfortran.dg/vect/vect.exp ...
FAIL: gfortran.dg/vect/vect-3.f90  -O  scan-tree-dump-times vect "Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-3.f90  -O  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "vectorized 1 loops" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/pr19049.f90  -O  scan-tree-dump-times vect "complicated access pattern" 1
Comment 6 Dominique d'Humieres 2008-11-23 00:32:01 UTC
(1) It seems that the failure of gfortran.dg/array_memset_2.f90 comes from a too broad regexp for scan-tree-dump-times: grep memset array_memset_2.f90.003t.original gives

          _gfortran_runtime_error_at (&"At line 8 of file /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/array_memset_2.f90"[1]{lb: 1 sz: 1}, &"Array reference out of bounds, upper bound of dimension 2 of array \'a\' exceeded (%ld > %ld)"[1]{lb: 1 sz: 1}, 1, (<unnamed-signed:32>) ubound.2);
          _gfortran_runtime_error_at (&"At line 8 of file /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/array_memset_2.f90"[1]{lb: 1 sz: 1}, &"Array reference out of bounds, upper bound of dimension 2 of array \'a\' exceeded (%ld > %ld)"[1]{lb: 1 sz: 1}, (<unnamed-signed:32>) NON_LVALUE_EXPR <D.1514>, (<unnamed-signed:32>) ubound.2);
          _gfortran_runtime_error_at (&"At line 8 of file /opt/gcc/_gcc_clean/gcc/testsuite/gfortran.dg/array_memset_2.f90"[1]{lb: 1 sz: 1}, &"Array reference out of bounds for array \'a\', upper bound of dimension 1  exceeded (%ld > %ld)"[1]{lb: 1 sz: 1}, 1, (<unnamed-signed:32>) ubound.0);
  (void) __builtin_memset ((void *) &b, 0, 8);
  (void) __builtin_memset ((void *) &c, 0, 8);

Either the regexp or the name of the test should be changed.

(2) The failure of gfortran.dg/bound_2.f90 comes from " Incorrect size in SOURCE argument to RESHAPE intrinsic: is 9, should be 4".  This is wrong, the standard says:

"If PAD is absent or of size zero, the size of SOURCE shall be greater than or equal to PRODUCT (SHAPE)."

(3) I think the failure of gfortran.dg/forall_13.f90: "Array reference out of bounds for array 'p', upper bound of dimension 1 exceeded (4 > 3)", is also wrong.
Comment 7 Thomas Koenig 2008-11-23 08:54:50 UTC
(In reply to comment #6)

> (2) The failure of gfortran.dg/bound_2.f90 comes from " Incorrect size in
> SOURCE argument to RESHAPE intrinsic: is 9, should be 4".  This is wrong, the
> standard says:
> 
> "If PAD is absent or of size zero, the size of SOURCE shall be greater than or
> equal to PRODUCT (SHAPE)."

You're right; this is now PR 38234.


> (3) I think the failure of gfortran.dg/forall_13.f90: "Array reference out of
> bounds for array 'p', upper bound of dimension 1 exceeded (4 > 3)", is also
> wrong.

This is PR 36091.

We should run the testsuite with -fbounds-check to catch
this kind of thing.
Comment 8 Dominique d'Humieres 2008-11-23 20:52:30 UTC
For gfortran.dg/g77/dnrm2.f the failure comes from the old style array declaration:

     double precision   dx(1), cutlo, cuthi, hitest, sum, xmax,zero,one

If 'dx(1)' is replaced by 'dx(*)', -fbounds-check does not detect any error (which may be wrong, but I don't think there is any way to detect the problem with a local analysis).
Comment 9 Dominique d'Humieres 2008-11-23 21:02:04 UTC
In addition to comment #8, the bound check would be possible using:

     double precision   dx(n), cutlo, cuthi, hitest, sum, xmax,zero,one
Comment 10 Dominique d'Humieres 2008-11-23 22:39:07 UTC
With the following changes:

Only in ../_gcc_clean/gcc/testsuite/gfortran.dg/: array_memset_2.f90
Only in gcc/testsuite/gfortran.dg/: array_setmem_2.f90

--- ../_gcc_clean/gcc/testsuite/gfortran.dg/pr37243.f	2008-09-04 19:10:20.000000000 +0200
+++ gcc/testsuite/gfortran.dg/pr37243.f	2008-11-23 22:54:23.000000000 +0100
@@ -34,7 +34,7 @@
       IF (J .GT. N) GO TO 320
       DO 240 K = 1,N
   240 V(K,I) = ZERO
-      CALL DAXPY(N,DUM,V(1,II),1,V(1,I),1)
+      CALL DAXPY(N,DUM,V(1,I),1,V(1,I),1)
   260 CONTINUE
       DUMI = ZERO
       DO 280 K = 1,N

--- ../_gcc_clean/gcc/testsuite/gfortran.dg/g77/dnrm2.f	2007-11-07 10:25:55.000000000 +0100
+++ gcc/testsuite/gfortran.dg/g77/dnrm2.f	2008-11-23 22:53:37.000000000 +0100
@@ -26,7 +26,7 @@
 
       double precision function dnrm2 ( n, dx, incx)
       integer i, incx, ix, j, n, next
-      double precision   dx(1), cutlo, cuthi, hitest, sum, xmax,zero,one
+      double precision   dx(n), cutlo, cuthi, hitest, sum, xmax,zero,one
       data   zero, one /0.0d0, 1.0d0/
       data cutlo, cuthi / 8.232d-11,  1.304d19 /
       j = 0

I only get the following failures with -fbounds-check:

FAIL: gfortran.dg/forall_13.f90  -O0  execution test
FAIL: gfortran.dg/forall_13.f90  -O1  execution test
FAIL: gfortran.dg/forall_13.f90  -O2  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer -funroll-loops  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  execution test
FAIL: gfortran.dg/forall_13.f90  -O3 -g  execution test
FAIL: gfortran.dg/forall_13.f90  -Os  execution test
FAIL: gfortran.dg/ldist-1.f90  -O  scan-tree-dump-times ldist "distributed: split to 4 loops" 1
FAIL: gfortran.dg/ltrans-7.f90  -O  scan-tree-dump-times ltrans "transformed loop" 1
FAIL: gfortran.dg/reassoc_4.f  -O  scan-tree-dump-times reassoc1 "[0-9] \* " 22
FAIL: gfortran.dg/vect/vect-3.f90  -O  scan-tree-dump-times vect "Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-3.f90  -O  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "vectorized 1 loops" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/pr19049.f90  -O  scan-tree-dump-times vect "complicated access pattern" 1

So, but for pr36091, the failures are expected regexps changed by -fbounds-check which is not too surprising.

Comment 11 Daniel Franke 2009-01-03 20:28:59 UTC
PR27989 and PR30939 essentially describe the same problem, once with an implicit, once with an explicit interface. The explicit case is sort-of solved, the implicit case will be if we ever get whole-file checking.

Do we need to keep both open? Can we merge them, close both and/or open a new one that clarifies what needs to be done?
Comment 12 Daniel Franke 2009-01-03 21:01:41 UTC
(In reply to comment #11)
Count PR32317 in as well.