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]

gcc-2.95.2, '-O', operator '%=' gives wrong result


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

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