https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106399
Bug ID: 106399 Summary: Wrong debug info for function with nested function under O0 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: --- Affected versions: gcc 11.1.0 (Ubuntu 20.04.2), since gcc 9 The debugger print `a` with a uninitialized value while `a` should be 3 at the breakpoint. (terminal) $ cat a.c && gcc -g -OO a.c int foo(int a) { int a2() { return a * a; } return a2(); } int main() { return foo(3) - 9; } -------------------- (terminal) $ gdb a.out (gdb) b foo Breakpoint 1 at 0x401188: file a.c, line 1. (gdb) r Breakpoint 1, foo (a=0) at a.c:1 <- **BUG**: a should be 3 1 int foo(int a)