public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31270]  New: print subscript value and array bounds when out-of-bounds error occurs
@ 2007-03-19 22:02 vivekrao4 at yahoo dot com
  2007-03-23 21:32 ` [Bug fortran/31270] " fxcoudert at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vivekrao4 at yahoo dot com @ 2007-03-19 22:02 UTC (permalink / raw)
  To: gcc-bugs

For the code

program xcheck
implicit none
integer :: i,ivec(2)
ivec = 0
do i=1,3
   if (i**2 < 10) print*,ivec(i)
end do
end program xcheck

gfortran -Wall -fbounds-check

for mingw 4.3.0 20070315

gives at run time

Fortran runtime error: Array reference out of bounds for array 'ivec', upper
bound of dimension 1 exceeded (in file 'xbounds_check.f90', at line 6)
           0
           0

This is good, but g95 is a little more informative, identifyng the value of the
out-of-bound subscript and the relevant dimension of the array, saying

 0
 0
At line 6 of file xbounds_check.f90 (Unit 6)
Traceback: not available, compile with -ftrace=frame or -ftrace=full
Fortran runtime error: Array element out of bounds: 3 in (1:2), dim=1

Vivek Rao


-- 
           Summary: print subscript value and array bounds when out-of-
                    bounds error occurs
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vivekrao4 at yahoo dot com


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


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

* [Bug fortran/31270] print subscript value and array bounds when out-of-bounds error occurs
  2007-03-19 22:02 [Bug fortran/31270] New: print subscript value and array bounds when out-of-bounds error occurs vivekrao4 at yahoo dot com
@ 2007-03-23 21:32 ` fxcoudert at gcc dot gnu dot org
  2007-08-05 13:42 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-23 21:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fxcoudert at gcc dot gnu dot org  2007-03-23 21:32 -------
We could do that, I even know precisely how and it's not too hard. It requires
creating a call to a va_arg function in the front-end, which I would need to
research because I've never done that.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fxcoudert at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-23 21:32:11
               date|                            |


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


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

* [Bug fortran/31270] print subscript value and array bounds when out-of-bounds error occurs
  2007-03-19 22:02 [Bug fortran/31270] New: print subscript value and array bounds when out-of-bounds error occurs vivekrao4 at yahoo dot com
  2007-03-23 21:32 ` [Bug fortran/31270] " fxcoudert at gcc dot gnu dot org
@ 2007-08-05 13:42 ` fxcoudert at gcc dot gnu dot org
  2007-08-05 14:06 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-05 13:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2007-08-05 13:42 -------
(In reply to comment #1)
> It requires
> creating a call to a va_arg function in the front-end, which I would need to
> research because I've never done that.

Well, it took more time than I thought, but I did my research... how does this
look like?

$ cat a.f90
program xcheck
implicit none
integer :: i,ivec(2)
ivec = 0
do i=1,3
   if (i**2 < 10) print*,ivec(i)
end do
end program xcheck
$ gfortran a.f90 -fbounds-check && ./a.out
           0
           0
At line 6 of file a.f90
Fortran runtime error: Array reference out of bounds for array 'ivec', upper
bound of dimension 1 exceeded, 3 is greater than 2


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
           Keywords|                            |diagnostic, patch
   Last reconfirmed|2007-03-23 21:32:11         |2007-08-05 13:42:40
               date|                            |
   Target Milestone|---                         |4.3.0


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


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

* [Bug fortran/31270] print subscript value and array bounds when out-of-bounds error occurs
  2007-03-19 22:02 [Bug fortran/31270] New: print subscript value and array bounds when out-of-bounds error occurs vivekrao4 at yahoo dot com
  2007-03-23 21:32 ` [Bug fortran/31270] " fxcoudert at gcc dot gnu dot org
  2007-08-05 13:42 ` fxcoudert at gcc dot gnu dot org
@ 2007-08-05 14:06 ` fxcoudert at gcc dot gnu dot org
  2007-08-10 22:12 ` fxcoudert at gcc dot gnu dot org
  2007-08-10 22:13 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-05 14:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2007-08-05 14:06 -------
Created an attachment (id=14026)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14026&action=view)
Patch


-- 


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


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

* [Bug fortran/31270] print subscript value and array bounds when out-of-bounds error occurs
  2007-03-19 22:02 [Bug fortran/31270] New: print subscript value and array bounds when out-of-bounds error occurs vivekrao4 at yahoo dot com
                   ` (2 preceding siblings ...)
  2007-08-05 14:06 ` fxcoudert at gcc dot gnu dot org
@ 2007-08-10 22:12 ` fxcoudert at gcc dot gnu dot org
  2007-08-10 22:13 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-10 22:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fxcoudert at gcc dot gnu dot org  2007-08-10 22:12 -------
Subject: Bug 31270

Author: fxcoudert
Date: Fri Aug 10 22:12:04 2007
New Revision: 127352

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127352
Log:
        PR fortran/31270

        * trans.c (gfc_trans_runtime_check): Reorder arguments and
        add extra variable arguments. Hand them to the library function.
        * trans.h (gfc_trans_runtime_check): Update prototype.
        * trans-array.c (gfc_trans_array_bound_check): Issue more
        detailled error messages.
        (gfc_conv_array_ref): Likewise.
        (gfc_conv_ss_startstride): Likewise.
        (gfc_trans_dummy_array_bias): Reorder arguments to
        gfc_trans_runtime_check.
        * trans-expr.c (gfc_conv_substring): Issue more detailled
        error messages.
        (gfc_conv_function_call): Reorder arguments to gfc_trans_runtime_check.
        * trans-stmt.c (gfc_trans_goto): Likewise.
        * trans-io.c (set_string): Reorder arguments to
        gfc_trans_runtime_check and issue a more detailled error message.
        * trans-decl.c (gfc_build_builtin_function_decls): Make
        runtime_error and runtime_error_at handle a variable number of
        arguments.
        * trans-intrinsic.c (gfc_conv_intrinsic_bound): Reorder arguments
        to gfc_trans_runtime_check.
        (gfc_conv_intrinsic_minmax): Likewise.
        (gfc_conv_intrinsic_repeat): Issue more detailled error messages.

        * runtime/error.c (runtime_error_at): Add a variable number of
        arguments.
        * libgfortran.h (runtime_error_at): Update prototype.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/fortran/trans-io.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/fortran/trans.c
    trunk/gcc/fortran/trans.h
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/libgfortran.h
    trunk/libgfortran/runtime/error.c


-- 


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


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

* [Bug fortran/31270] print subscript value and array bounds when out-of-bounds error occurs
  2007-03-19 22:02 [Bug fortran/31270] New: print subscript value and array bounds when out-of-bounds error occurs vivekrao4 at yahoo dot com
                   ` (3 preceding siblings ...)
  2007-08-10 22:12 ` fxcoudert at gcc dot gnu dot org
@ 2007-08-10 22:13 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-08-10 22:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2007-08-10 22:12 -------
Fixed.


-- 

fxcoudert at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-08-10 22:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-19 22:02 [Bug fortran/31270] New: print subscript value and array bounds when out-of-bounds error occurs vivekrao4 at yahoo dot com
2007-03-23 21:32 ` [Bug fortran/31270] " fxcoudert at gcc dot gnu dot org
2007-08-05 13:42 ` fxcoudert at gcc dot gnu dot org
2007-08-05 14:06 ` fxcoudert at gcc dot gnu dot org
2007-08-10 22:12 ` fxcoudert at gcc dot gnu dot org
2007-08-10 22:13 ` fxcoudert 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).