public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/29220] New: GDB prints wrong value at -O2
@ 2022-06-02  1:27 yangyibiao at outlook dot com
  2022-06-02 16:46 ` [Bug gdb/29220] " tromey at sourceware dot org
  2022-06-05 17:53 ` tromey at sourceware dot org
  0 siblings, 2 replies; 3+ messages in thread
From: yangyibiao at outlook dot com @ 2022-06-02  1:27 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=29220

            Bug ID: 29220
           Summary: GDB prints wrong value at -O2
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: yangyibiao at outlook dot com
  Target Milestone: ---

$ gdb --version
GNU gdb (GDB) 13.0.50.20220531-git

$ gcc --version
gcc (GCC) 13.0.0 20220530 (experimental)

$ cat -n small.c
     1  void foo(int *a)
     2  {
     3    (*a)++;
     4  }
     5
     6  int main ()
     7  {
     8    int a = 0;
     9    foo (&a);
    10    return 0;
    11  }

$ gcc -O2 -g small.c; gdb -q a.out
Reading symbols from a.out...
(gdb) b main
Breakpoint 1 at 0x401020: file small.c, line 10.
(gdb) r
Starting program: /root/DeVIL/a.out

Breakpoint 1, main () at small.c:10
10        return 0;
(gdb) info locals
a = 0
(gdb) 

### The expected value is "a = 1". However, gdb prints "a = 0". I know that
this function is optimized out. I was wondering that a better solution for this
is that gdb report the value of a is optmized out as well.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2022-06-05 17:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  1:27 [Bug gdb/29220] New: GDB prints wrong value at -O2 yangyibiao at outlook dot com
2022-06-02 16:46 ` [Bug gdb/29220] " tromey at sourceware dot org
2022-06-05 17:53 ` tromey at sourceware dot 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).