here is a little example that shows how to do this
until the runtime error can print out the file name
and line number....
[bdavis@gfortran ~]$ cat a.f
integer x(10)
do i = 1,25
x(i) = i
enddo
end
[bdavis@gfortran ~]$ /usr/local/bin/gfortran -static
-fbounds-check a.f
[bdavis@gfortran ~]$ gdb a.out
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General
Public License, and you are
welcome to change it and/or distribute copies of it
under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show
warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using
host libthread_db library
"/lib/tls/libthread_db.so.1".
(gdb) break _gfortran_runtime_error
Breakpoint 1 at 0x8048996: file
../../../gcc/libgfortran/runtime/error.c, line 328.
(gdb) run
Starting program: /home/bdavis/a.out
Breakpoint 1, *_gfortrani_runtime_error (
message=0x80aaa2c "Array reference out of bounds")
at ../../../gcc/libgfortran/runtime/error.c:329
329 ../../../gcc/libgfortran/runtime/error.c: No
such file or directory.
in ../../../gcc/libgfortran/runtime/error.c
(gdb) bt
#0 *_gfortrani_runtime_error (
message=0x80aaa2c "Array reference out of bounds")
at ../../../gcc/libgfortran/runtime/error.c:329
#1 0x08048253 in MAIN__ ()
#2 0x080482a7 in main (argc=1, argv=0xbfe4f0c4)
at ../../../gcc/libgfortran/fmain.c:18
(gdb)
HTH,
bud davis
--- Tim Prince <timothyprince@sbcglobal.net> wrote:
Roderick Johnstone wrote:
Hi
I've been using the -fbounds-check option to
gfortran to check for
illegal array element accesses at run time. Is it
possible to get the
source code line number where the illegal access
was made? If so how?
with -g, running under gdb?