[Bug c/68046] New: -ftrapv doesn't catch leaq-based overflows on x86-64
eggert at gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Oct 21 22:39:00 GMT 2015
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.
More information about the Gcc-bugs
mailing list