public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/49888] New: VTA: -O2 -g variable value changes, it does not change in the source
@ 2011-07-28 18:04 jan.kratochvil at redhat dot com
  2012-05-23  9:36 ` [Bug debug/49888] " aoliva at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-07-28 18:04 UTC (permalink / raw)
  To: gcc-bugs

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.


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

end of thread, other threads:[~2013-01-18 11:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 18:04 [Bug debug/49888] New: VTA: -O2 -g variable value changes, it does not change in the source jan.kratochvil at redhat dot com
2012-05-23  9:36 ` [Bug debug/49888] " aoliva at gcc dot gnu.org
2012-06-13 21:44 ` aoliva at gcc dot gnu.org
2012-06-13 21:58 ` aoliva at gcc dot gnu.org
2012-06-13 22:10 ` jan.kratochvil at redhat dot com
2012-06-22  1:31 ` aoliva at gcc dot gnu.org
2012-06-22  1:34 ` aoliva at gcc dot gnu.org
2012-06-28  7:41 ` aoliva at gcc dot gnu.org
2012-07-06 11:37 ` aoliva at gcc dot gnu.org
2012-11-08  2:57 ` aoliva at gcc dot gnu.org
2013-01-16  4:32 ` aoliva at gcc dot gnu.org
2013-01-18 10:59 ` aoliva at gcc dot gnu.org
2013-01-18 11:01 ` aoliva at gcc dot gnu.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).