This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug debug/49888] New: VTA: -O2 -g variable value changes, it does not change in the source


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

           Summary: VTA: -O2 -g variable value changes, it does not change
                    in the source
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jan.kratochvil@redhat.com
                CC: aoliva@gcc.gnu.org
            Target: x86_64-unknown-linux-gnu


static int v;
static void __attribute__((noinline, noclone))
f (int *p)
{
  int c = *p;
  v = c;
  *p = 2;
  v = 0; /* break-here */
}
int
main ()
{
  int v = 2;
  f (&v);
  return 0;
}
--------------------------------------------------------------------------------
FAIL: gcc (GCC) 4.5.4 20110728 (prerelease)
FAIL: gcc (GCC) 4.6.2 20110728 (prerelease)
FAIL: gcc (GCC) 4.7.0 20110728 (experimental)
-Wall -g -O2
--------------------------------------------------------------------------------
Breakpoint 1, f (p=0x7fffffffda44) at 8.c:7
7      *p = 2;
(gdb) disass
Dump of assembler code for function f:
=> 0x0000000000400480 <+0>:    movl   $0x2,(%rdi)
   0x0000000000400486 <+6>:    movl   $0x0,0x2003e8(%rip)        # 0x600878 <v>
   0x0000000000400490 <+16>:    retq   
End of assembler dump.
(gdb) p c
$1 = 1
(gdb) stepi
8      v = 0; /* break-here */
(gdb) p c

Actual:
$2 = 2
Expected:
$2 = 1

`c' is never changed in the source code, it should not change in runtime.
    <63>   DW_AT_location    : 2 byte block: 75 0       (DW_OP_breg5 (rdi): 0)

<optimized out> would be better than a wrong value.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]