Environment:
gcc (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4) from Ubuntu repositories
Ubuntu 7.04 2.6.20-16-generic kernel
GNU gdb 6.6-debian

I run this program in GDB, and put a breakpoing right before the call to
whatever(). At this point, I print "a", and the value is no good, but the
variable is uninitialized so that's expected. However, after the other
statements which set the value of "a", printing "a" still show the
uninitialized value.

This was compiled simply using "gcc -g test.c" and run using "gdb ./a.out".

=== test.c ===============
int
main (
  int argc,
  char *argv[])
{
  int a;

  void whatever ()
  {
    a = 123;
  }

  whatever();
  a = 321;

  return 0;
}
==========================

It looks like gdb decodes the address as 4 bytes too low, gcc says its location
is DW_OP_fbreg -16. I don't know if this is a gdb or a gcc problem, but from
what I've been told a variable not updating is almost always a compiler bug.
I've also submitted the issue to gdb's bugtracking system
(http://sourceware.org/cgi-bin/gnatsweb.pl) as issue 2319.

Thanks,

Seth Grover


-- 
           Summary: gcc-compiled program possibly reporting wrong variable
                    address to gdb
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sethdgrover at gmail dot com


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

Reply via email to