From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4897 invoked by alias); 22 Oct 2015 08:47:13 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 4687 invoked by uid 48); 22 Oct 2015 08:47:09 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/68046] -ftrapv doesn't catch leaq-based overflows on x86-64 Date: Thu, 22 Oct 2015 08:47:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 5.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: DUPLICATE X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-10/txt/msg01813.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68046 --- Comment #4 from Richard Biener --- 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).