This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/11175] New: -ftrapv breaks modulo
- From: "hochstein at algo dot informatik dot tu-darmstadt dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Jun 2003 14:16:26 -0000
- Subject: [Bug c/11175] New: -ftrapv breaks modulo
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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;
}