[Bug middle-end/86680] possible gcc optimization

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jul 27 20:49:00 GMT 2018


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.

More information about the Gcc-bugs mailing list