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.