https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106400
Bug ID: 106400 Summary: Wrong debug info for function parameter in aarch64 Product: gcc Version: 12.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: --- This bug occured in aarch64, not in x86. GDB print the parameter x=65535 while the correct value should be 3. It seems the value has not been stored in stack at the breakpoint, and x has correct value after executing the store instruction. Affected versions: gcc 12.1.0 (Ubuntu 20.04.2) (terminal) $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/gcc-12.1.0/libexec/gcc/aarch64-unknown-linux-gnu/12.1.0/lto-wrapper Target: aarch64-unknown-linux-gnu Configured with: /var/tmp/gcc-12.1.0_source/gcc-12.1.0/configure --prefix=/opt/gcc-12.1.0 --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --without-included-gettext Thread model: posix Supported LTO compression algorithms: zlib gcc version 12.1.0 (GCC) (terminal) $ cat a.c && gcc -g -OO a.c int bar(int x) { return x; } __attribute__((optimize("Og"))) int foo(const char *fmt, ...) { return bar(3); } int main() { return foo("fmt") == 3; } -------------------- (terminal) $ gdb a.out (gdb) b bar Breakpoint 1 at 0x4005e4: file a.c, line 1. (gdb) r Breakpoint 1, bar (x=65535) at a.c:1 <-- bug : should be 3 1 int bar(int x) { B+>0x4005e4 <bar>: sub sp, sp, #0x10 <- x=65535 0x4005e8 <bar+4>: str w0, [sp, #12] 0x4005ec <bar+8>: ldr w0, [sp, #12] <- x=3 0x4005f0 <bar+12>: add sp, sp, #0x10