[Bug middle-end/70871] questionable optimisation in fold-const.c

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Apr 29 09:32:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70871

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-04-29
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Assembler w/o asan:

somefunc:
.LFB0:
        .cfi_startproc
        subq    $24, %rsp
        .cfi_def_cfa_offset 32
        movq    $0, 8(%rsp)
        leaq    8(%rsp), %rdi
        call    call
        movabsq $280379743272960, %rdx
        movq    8(%rsp), %rax
        testq   %rdx, 40(%rax)
        setne   %al
        movzbl  %al, %eax
        addq    $24, %rsp
        .cfi_def_cfa_offset 8
        ret

if my math is correct this loads 8 bytes from &px->i and accesses two stray
bytes after the object.  That's actually fine as alignment guarantees of
the type ensure this won't cross a page boundary.  If we misalign it by
making it packed the folding doesn't apply.

So while the folding is strange it isn't incorrect but it messes with ASAN.


More information about the Gcc-bugs mailing list