public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jan.kratochvil at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/49888] New: VTA: -O2 -g variable value changes, it does not change in the source
Date: Thu, 28 Jul 2011 18:04:00 -0000	[thread overview]
Message-ID: <bug-49888-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2011-07-28 18:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28 18:04 jan.kratochvil at redhat dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-49888-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).