https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90197
Bug ID: 90197 Summary: [8/9 Regression] Cannot step through simple loop at -O -g Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- Compiling: __attribute__((noipa)) void test (unsigned int *dst, unsigned int base, int count) { for (int i = 0; i < count; ++i, base += 15) dst[i] = base; } int main (void) { unsigned int dst[100]; test (dst, 0x4000, 100); } with -O -g and launching with recent gdb trunk (and stock gdb): (gdb) break test Breakpoint 1 ... (gdb) run Starting program: ... Breakpoint 1, test ... 5 for (int i = 0; i < count; ++i, base += 15) (gdb) next 6 dst[i] = base; (gdb) next __libc_start_main (main=... i.e. it isn't possible to step through each iteration of the loop. With gcc 7 this worked even for -O2 -g. The test works with -O -fno-tree-ch -g (and thus also with -Og). For -O2 -fno-tree-ch -g we get: (gdb) break test Breakpoint 1 ... (gdb) run Starting program: ... Breakpoint 1, test ... 5 for (int i = 0; i < count; ++i, base += 15) (gdb) next __libc_start_main ... With just -O2 -g we get the same as for -O -g. A breakpoint on the loop body (line 6) hits for each iteration of the loop though. As you can tell, this isn't my area, so I'm not sure whether it's actually a gdb bug (or a dup).