https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61893

            Bug ID: 61893
           Summary: Constant folding inhibits trapping with -ftrapv
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org

int
iaddv (void)
{
  return __INT_MAX__ + 1;
}

> ./cc1 -quiet t2.c -ftrapv
t2.c: In function 'iaddv':
t2.c:4:24: warning: integer overflow in expression [-Woverflow]
     return __INT_MAX__ + 1;
                        ^

iaddv:
.LFB0:
        .cfi_startproc
        pushq   %rbp
        .cfi_def_cfa_offset 16
        .cfi_offset 6, -16
        movq    %rsp, %rbp
        .cfi_def_cfa_register 6
        movl    $-2147483648, %eax
        popq    %rbp
        .cfi_def_cfa 7, 8
        ret

Reply via email to