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/11175] New: -ftrapv breaks modulo


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: -ftrapv breaks modulo
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: hochstein@algo.informatik.tu-darmstadt.de
                CC: gcc-bugs@gcc.gnu.org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

The following code compiled with
gcc -g -ftrapv tst.cpp -o tst
wrongly produces
(3-j) % 3 = -6
(3-j) % 3 = -7
(3-j) % 3 = -8
while it works correctly without -ftrapv. 

#include <stdio.h>
int main()
{
  int j;
  for(j = 0; j < 3; j ++)
    printf("(3-j) % 3 = %d\n",(3-j)%3);
  return 0;
}


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