https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95098
Bug ID: 95098 Summary: Out of scope variable visible during debugging at Og Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: massarelli at diag dot uniroma1.it Target Milestone: --- Variable l_9 is visible when the debugger hit line 4. $ cat a.c int g_2, a; int b() { char l_10; for (g_2 = 21; (g_2 < (-27)); g_2 = 0) return g_2; { int *l_9 = &a; return; } } int main() { b(); } $ 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 20200508 (experimental) (GCC) $ lldb -v lldb version 11.0.0 clang revision 23cbea9a04e023d5b79dfee5964fae769340c993 llvm revision 23cbea9a04e023d5b79dfee5964fae769340c993 $ gcc -Og -g -o opt a.c $ lldb opt (lldb) target create "opt" Current executable set to 'opt' (x86_64). (lldb) b main Breakpoint 1: where = opt`main at a.c:11:14, address = 0x000000000040048d (lldb) r Process 61 launched: 'opt' (x86_64) Process 61 stopped * thread #1, name = 'opt', stop reason = breakpoint 1.1 frame #0: 0x000000000040048d opt`main at a.c:11:14 8 return; 9 } 10 } -> 11 int main() { b(); } (lldb) s Process 61 stopped * thread #1, name = 'opt', stop reason = step in frame #0: 0x0000000000400482 opt`b at a.c:4:12 1 int g_2, a; 2 int b() { 3 char l_10; -> 4 for (g_2 = 21; (g_2 < (-27)); g_2 = 0) 5 return g_2; 6 { 7 int *l_9 = &a; (lldb) frame var -s -g LOCAL: (char) l_10 = <no location, value may have been optimized out> STATIC: (int *) l_9 = 0x000000000060102c GLOBAL: (int) g_2 = 0 GLOBAL: (int) a = 0