public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/100969] New: Incorrect debug info for struct under O1 optimization
@ 2021-06-08 15:37 liyd2021 at gmail dot com
  2021-06-09  6:41 ` [Bug debug/100969] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: liyd2021 at gmail dot com @ 2021-06-08 15:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100969
           Summary: Incorrect debug info for struct under O1 optimization
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liyd2021 at gmail dot com
  Target Milestone: ---

Reproduced on: gcc 11.1.0, 9.3.0, 8.4.0 with gdb or lldb (Ubuntu 20.04.2)

$ cat test.c
struct foo { int a, b, c; };

void not_opt(struct foo x) __attribute__((noipa));
void not_opt(struct foo x) {}

int main ()
{
struct foo f = { 7, 8, 9 };
not_opt(f);
return 0;
}

Compile command:
$ gcc -g -O1 test.c -o test
$ gcc --verbose
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/vm/opt/gcc-11.1.0/libexec/gcc/x86_64-unknown-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/vm/var/tmp/vm/gcc-11.1.0_source/gcc-11.1.0/configure
--prefix=/home/vm/opt/gcc-11.1.0 --enable-bootstrap --enable-shared
--enable-threads=posix --enable-checking=release --with-system-zlib
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-linker-build-id
--enable-languages=c,c++,lto --disable-vtable-verify
--with-default-libstdcxx-abi=new --enable-libstdcxx-debug
--without-included-gettext --enable-plugin --disable-initfini-array
--disable-libgcj --enable-plugin --disable-multilib --with-tune=generic
--build=x86_64-unknown-linux-gnu --target=x86_64-unknown-linux-gnu
--host=x86_64-unknown-linux-gnu --with-pkgversion=vm
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.1.0

Debugging with gdb:
(gdb) l
1 struct foo { int a, b, c; };
2
3 void not_opt(struct foo x) __attribute__((noipa));
4 void not_opt(struct foo x) {}
5
6 int main ()
7 {
8 struct foo f = { 7, 8, 9 };
9 not_opt(f);
10 return 0;
(gdb) b 9
(gdb) r
(gdb) print f
$1 = {a = 7, b = 8, c = 0} <-- **BUG**: c should be 9

LLDB also reports c = 0. Should be a debug-info bug.

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

* [Bug debug/100969] Incorrect debug info for struct under O1 optimization
  2021-06-08 15:37 [Bug debug/100969] New: Incorrect debug info for struct under O1 optimization liyd2021 at gmail dot com
@ 2021-06-09  6:41 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-09  6:41 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |wrong-debug
   Last reconfirmed|                            |2021-06-09
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
 <2><85>: Abbrev Number: 6 (DW_TAG_variable)
    <86>   DW_AT_name        : f
    <88>   DW_AT_decl_file   : 1
    <89>   DW_AT_decl_line   : 8
    <8a>   DW_AT_decl_column : 12
    <8b>   DW_AT_type        : <0x2d>
    <8f>   DW_AT_location    : 2 byte block: 91 64      (DW_OP_fbreg: -28)

but

(gdb) disassemble
Dump of assembler code for function main:
   0x0000000000400497 <+0>:     sub    $0x18,%rsp
   0x000000000040049b <+4>:     movl   $0x7,0x4(%rsp)
   0x00000000004004a3 <+12>:    movl   $0x8,0x8(%rsp)
=> 0x00000000004004ab <+20>:    mov    0x4(%rsp),%rdi
   0x00000000004004b0 <+25>:    mov    $0x9,%esi
   0x00000000004004b5 <+30>:    call   0x400496 <not_opt>

you see the var on the frame has not been fully initialized but instead
the full variable is in the call argument registers %rdi and %esi only.

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

end of thread, other threads:[~2021-06-09  6:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 15:37 [Bug debug/100969] New: Incorrect debug info for struct under O1 optimization liyd2021 at gmail dot com
2021-06-09  6:41 ` [Bug debug/100969] " rguenth 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).