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 rtl-optimization/19020] New: addition on integers doesn't trap


The following code should abort at runtime when compiled with -ftrapv:

#include <limits.h>

int __attribute__((noinline))
iaddv (int a, int b)
{
  return a + b;
}

int main(void)
{
  iaddv (INT_MAX, 1);
  return 0;
}

It doesn't in 64-bit mode:
[eric@localhost native]$ gcc-4.0 -o addv addv.c -ftrapv
[eric@localhost native]$ ./addv
[eric@localhost native]$ gcc-4.0 -o addv addv.c -ftrapv -m32
[eric@localhost native]$ ./addv
Aborted

The problem originates in .03.jump: the libcall to __addvdi3 is eliminated.

-- 
           Summary: addition on integers doesn't trap
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ebotcazou at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-*-*
  GCC host triplet: x86_64-*-*
GCC target triplet: x86_64-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19020


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