This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc-2.95.2, '-O', operator '%=' gives wrong result
- To: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>
- Subject: gcc-2.95.2, '-O', operator '%=' gives wrong result
- From: "Krakowczyk, Andreas" <Andreas dot Krakowczyk at fujitsu-siemens dot com>
- Date: Wed, 27 Sep 2000 16:03:52 +0200
- Cc: "Unruh, Erwin" <Erwin dot Unruh at fujitsu-siemens dot com>, "'Andreas dot Krakowczyk at t-online dot de'" <Andreas dot Krakowczyk at t-online dot de>
Hi there,
The following test program gives wrong results when compiled with option
'-O' but works fine without optimization.
The compiler version I use is gcc-2.95.2 on mips-sni-sysv4 .
The compiler command line is 'gcc -O test.c && ./a.out'.
This is the test program:
main () {
signed char a = 127;
signed char b = 126;
unsigned int c = 4294967295U;
printf ("a = 0x%02X (%d)\n", a, a);
printf ("b = 0x%02X (%d)\n", b, b);
printf ("c = 0x%04X (%d)\n", c, c);
a %= b % c;
if (a == 1)
printf ("test passed, %s results in %d\n", "a %= b % c", a);
else
printf ("test FAILED, %s results in %d\n", "a %= b % c", a);
}
Kind regards,
Andreas Krakowczyk
FSC EP LP AD C++
Andreas.Krakowczyk@fujitsu-siemens.com