This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc-2.95.2, '-O', operator '%=' gives wrong result
- To: "Krakowczyk, Andreas" <Andreas dot Krakowczyk at fujitsu-siemens dot com>
- Subject: Re: gcc-2.95.2, '-O', operator '%=' gives wrong result
- From: Neil Booth <NeilB at earthling dot net>
- Date: Wed, 27 Sep 2000 19:06:54 +0100
- Cc: "'gcc-bugs at gcc dot gnu dot org'" <gcc-bugs at gcc dot gnu dot org>,Geoff Keating <geoffk at cygnus dot com>,"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>
- References: <77821F56A593D4119FE5009027FD7622143A15@MCHRD21E>
Hi,
This looks like (another) example of a known problem GCC has with
signed chars / shorts when assigned immediate values. There is a
testcase in GNATS.
Neil.
Krakowczyk, Andreas wrote:-
> 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);
> }