This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/68046] New: -ftrapv doesn't catch leaq-based overflows on x86-64
- From: "eggert at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 21 Oct 2015 22:39:34 +0000
- Subject: [Bug c/68046] New: -ftrapv doesn't catch leaq-based overflows on x86-64
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68046
Bug ID: 68046
Summary: -ftrapv doesn't catch leaq-based overflows on x86-64
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: eggert at gnu dot org
Target Milestone: ---
On x86-64 for this program:
long i = 0x7fffffffffffffffL;
int main (void)
{
return i + 1 < i;
}
gcc -ftrapv -O2 -S generates this code:
main:
movq i(%rip), %rax
leaq 1(%rax), %rdx
cmpq %rdx, %rax
setg %al
movzbl %al, %eax
ret
which does not trap, even though the addition overflows.