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).

Reply via email to