public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/96002] New: Wrong argument value shown by gdb at Og
Date: Tue, 30 Jun 2020 11:45:10 +0000	[thread overview]
Message-ID: <bug-96002-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96002

            Bug ID: 96002
           Summary: Wrong argument value shown by gdb at Og
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: wrong-debug
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: massarelli at diag dot uniroma1.it
  Target Milestone: ---
          Keywords: wrong-debug

The second time line 5 is hit arguments p_21 is assigned a wrong value.

$ cat -n a.c
     1  int a, c;
     2  int *b[3];
     3  void d(int e, short f, int g, char p_21) {
     4    int h;
     5    for (; c < 3; c++)
     6      b[c] = &h;
     7  }
     8  int main() { d(a, 0, 1, 0); }

$ cat a.c
int a, c;
int *b[3];
void d(int e, short f, int g, char p_21) {
  int h;
  for (; c < 3; c++)
    b[c] = &h;
}
int main() { d(a, 0, 1, 0); }

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/tmp/gcc_build --disable-multilib
--enable-languages=c,c++
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200624 (experimental) (GCC) 

$ gcc -Og -g -o opt a.c

$ gdb opt
Reading symbols from opt...
(gdb) b main
Breakpoint 1 at 0x4004ad: file a.c, line 8.
(gdb) r
Starting program: opt 
Breakpoint 1, main () at a.c:8
8       int main() { d(a, 0, 1, 0); }
(gdb) s
d (e=0, f=f@entry=0, g=g@entry=1, p_21=p_21@entry=0 '\000') at a.c:5
5         for (; c < 3; c++)
(gdb) s
6           b[c] = &h;
(gdb) bt
#0  d (e=0, f=f@entry=0, g=g@entry=1, p_21=p_21@entry=0 '\000') at a.c:6
#1  0x00000000004004c7 in main () at a.c:8
(gdb) s
5         for (; c < 3; c++)
(gdb) bt
#0  d (e=0, f=f@entry=0, g=g@entry=1, p_21=124 '|', p_21@entry=0 '\000') at
a.c:5
#1  0x00000000004004c7 in main () at a.c:8
(gdb)

                 reply	other threads:[~2020-06-30 11:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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-96002-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).