This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/68046] -ftrapv doesn't catch leaq-based overflows on x86-64


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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note that -fsanitize-undefined doesn't properly handle

  volatile int x = __INT_MAX__ + 1;

which is in PR61893, it handles the case in this PR fine and with
trap-on-error more efficiently than -ftrapv:

main:
.LFB0:
        .cfi_startproc
        movq    i(%rip), %rax
        movq    %rax, %rdx
        addq    $1, %rdx
        jo      .L6
        cmpq    %rdx, %rax
        setg    %al
        movzbl  %al, %eax
        ret
.L6:
        ud2
        .cfi_endproc

of course you simply get a SIGILL (on x86_64), an option to use
abort () would be more "compatible" with how -ftrapv behaves
(abort is also used on targets that do not have a trapping instruction
defined).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]