https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95890
Bug ID: 95890 Summary: Probably wrong Line Information 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: --- $ cat a.c int a; void b() { short l_196 = a = 0; a+1; } int main() { b(); } $ cat -n a.c 1 int a; 2 void b() { 3 short l_196 = a = 0; 4 a+1; 5 } 6 int main() { b(); } 7 When compiled with gcc trunk and flag -Og -g, gdb 9.2 shows a step over line 4, while the add instruction does not exist in the assembly. When compiled with -O0 it correctly jumps to line 5, never showing the step over line 4. Even in the non optimized binary the add at line 4 is not translated in assembly. $ 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 -Og -g a.c -o a.out $ gdb a.out GNU gdb (GDB) 9.2 Reading symbols from a.out... (gdb) b main Breakpoint 1 at 0x400491: file a.c, line 6. (gdb) r Starting program: /home/stepping/output/a.out Breakpoint 1, main () at a.c:6 6 int main() { b(); } (gdb) s b () at a.c:3 3 short l_196 = a = 0; (gdb) s 4 a+1; (gdb) disassemble Dump of assembler code for function b: 0x0000000000400486 <+0>: movl $0x0,0x200b9c(%rip) # 0x60102c => 0x0000000000400490 <+10>: retq End of assembler dump.