https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86680
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Yeah. You probably need something like: void clear_bss1(void) { unsigned long *bss = __bss_start1; asm ("" : "+g" (bss)); while (bss < __bss_end1) *bss++ = 0UL; } to hide the UB from the optimizers; pointer arithmetics is only defined within the same object and similarly pointer comparison other than ==/!=, while the first function has two different objects.