public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/68046] New: -ftrapv doesn't catch leaq-based overflows on x86-64
@ 2015-10-21 22:39 eggert at gnu dot org
  2015-10-21 22:48 ` [Bug middle-end/68046] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: eggert at gnu dot org @ 2015-10-21 22:39 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-10-23  8:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-21 22:39 [Bug c/68046] New: -ftrapv doesn't catch leaq-based overflows on x86-64 eggert at gnu dot org
2015-10-21 22:48 ` [Bug middle-end/68046] " pinskia at gcc dot gnu.org
2015-10-21 23:46 ` joseph at codesourcery dot com
2015-10-22  8:19 ` rguenth at gcc dot gnu.org
2015-10-22  8:47 ` rguenth at gcc dot gnu.org
2015-10-22 11:44 ` rguenth at gcc dot gnu.org
2015-10-23  8:57 ` ebotcazou at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).