If I compile the following program with -gstabs+ under OSX 10.5.5 with gcc4.4

Using built-in specs.
Target: i386-apple-darwin8.10.1
Configured with: /tmp/gfortran-20081006/ibin/../gcc/configure
--prefix=/usr/local/gfortran --enable-languages=c,fortran
--with-gmp=/tmp/gfortran-20081006/gfortran_libs --enable-bootstrap
Thread model: posix
gcc version 4.4.0 20081006 (experimental) [trunk revision 140904] (GCC) 


      program hello

      integer a
      common /testcommon/a

      integer pos(3)

      a = 5

      pos(1) = 2
      pos(2) = 1
      pos(3) = 1

      write (*,*) "HELLO", A

      end

as follows:

gfortran -gstabs+ -o testcase testcase.f

Then I can correctly use gdb as shown below:

Breakpoint 1, MAIN__ () at testcase.f:1
1             program hello
(gdb) next
Current language:  auto; currently fortran
8             a = 5
(gdb) list
3             integer a
4             common /testcommon/a
5       
6             integer pos(3)
7       
8             a = 5
9       
10            pos(1) = 2
11            pos(2) = 1
12            pos(3) = 1

However, if I compile with -finit-local-zero like this:

gfortran -finit-local-zero -gstabs+ -o testcase testcase.f

The line numbers don't match the source code as shown below:

Breakpoint 1, MAIN__ () at testcase.f:1
1             program hello
(gdb) next
Current language:  auto; currently fortran
6             integer pos(3)
(gdb) list
1             program hello
2             
3             integer a
4             common /testcommon/a
5       
6             integer pos(3)
7       
8             a = 5
9       
10            pos(1) = 2
(gdb) quit

The compiler is apparently adding extra code to initizilize the variables but
not accounting for it in the line numbers.  This problem has existed as long as
the -finit-local-zero option has been avaliable in gfortran.  I can't test
other -g options as they don't generate usuable debug information on OSX.


-- 
           Summary: gfortran compiled with -gstabs+ on OSX emits incorrect
                    debug information if compiled with -finit-local-zero
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: chris dot walter at duke dot edu


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

Reply via email to