This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/68046] New: -ftrapv doesn't catch leaq-based overflows on x86-64


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]