public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27588]  New: -fbounds-check should catch substring out of range accesses
@ 2006-05-13 14:07 tobias dot burnus at physik dot fu-berlin dot de
  2006-05-13 14:07 ` [Bug fortran/27588] " tobias dot burnus at physik dot fu-berlin dot de
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-05-13 14:07 UTC (permalink / raw)
  To: gcc-bugs

Taken from http://www.polyhedron.com/pb05/linux/diagnose.html
------<CBND1.F>-------
! character bound error - local variable
      program cbnd1
      character*10 zz
      i = 2
      j = i+9
      zz(i:j) = 'abcdef'
      print * , zz
      end
----------------------
gfortran-4.2 -Wall -pedantic -fbounds-check CBND1.F
./a.out
 ^Aabcdef

Expected: Issue a run-time error message.

Examples of other compilers:

ifort64-9.1 -C -check all -warn all,nodec,interfaces -gen_interfaces -traceback
-fpe0 -fpstkchk CBND1.F
./a.out
forrtl: severe (408): fort: (4): Variable ZZ has substring ending point 11
which is greater than the variable length of 10


g95 -Wall -pedantic -fbounds-check -ftrace=full CBND1.F
./a.out
At line 6 of file CBND1.F
Traceback: (Innermost first)
Fortran runtime error: Substring reference out of bounds: (2:11) in string of
length 10

NAG: f95 -C=all -C=undefined -info -g -gline CBND1.F
Out of range: substring ending position 11 is greater than length 10
Program terminated by fatal error
In CBND1, line 6 of CBND1.F


The following is even detected at compile time by the intel and NAGf95
compilers (gfortran does not detect it at compile or runtime):
--------<CBND3.F>--------------
! Check character bound error - assign to dummy argument which is larger than
actual arg
      program cbnd3
      character*10 zz,zzz
      common /aaa/zz,zzz
      zz = '0000000000'
      zzz = '1111111111'

      call sub(zz)
      print * , zzz
      end
      subroutine sub(zz)
      character*11 zz
      zz = 'abcdef'
      print * , zz
      end
---------------------------


-- 
           Summary: -fbounds-check should catch substring out of range
                    accesses
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot burnus at physik dot fu-berlin dot de


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


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

end of thread, other threads:[~2007-01-31 10:24 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-13 14:07 [Bug fortran/27588] New: -fbounds-check should catch substring out of range accesses tobias dot burnus at physik dot fu-berlin dot de
2006-05-13 14:07 ` [Bug fortran/27588] " tobias dot burnus at physik dot fu-berlin dot de
2006-06-05 21:16 ` pault at gcc dot gnu dot org
2006-06-08  9:11 ` fxcoudert at gcc dot gnu dot org
2006-10-02 15:15 ` tobias dot burnus at physik dot fu-berlin dot de
2006-10-02 15:32 ` Francois-Xavier dot Coudert at ens dot fr
2006-10-05  8:08 ` patchapp at dberlin dot org
2006-11-10 20:46 ` burnus at gcc dot gnu dot org
2006-11-10 22:41 ` burnus at gcc dot gnu dot org
2006-11-11  1:25 ` patchapp at dberlin dot org
2006-11-15 10:13 ` burnus at gcc dot gnu dot org
2006-11-15 10:16 ` burnus at gcc dot gnu dot org
2006-12-01  2:06 ` chaoyingfu at gcc dot gnu dot org
2007-01-31 10:24 ` burnus 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).