From: uban AT mail DOT netnitco DOT net (Tom Uban) Subject: B19: gcc optimizer generates bad code 22 Mar 1998 06:05:19 -0800 Message-ID: <3.0.5.32.19980319121220.007ae970.cygnus.gnu-win32@mail.netnitco.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: gnu-win32 AT cygnus DOT com /* * When this simple code sample is compiled with the Cygnus B19.1 gcc * compiler using either -O2 or -O3, bad code is generated. * gcc -O2 test.c * or * gcc -O3 test.c * * This program should always print the number 4. When compiled * with -O2 or -O3 the number 1 is printed. The dissassembled output * seems to indicate that the loop code generation is broken. * * The result of gcc -v is: * Reading specs from C:\CYGNUS\B19\H-I386~1\lib\gcc-lib\i386-cygwin32\2.7-B19\specs * gcc driver version 2.7-B19 executing gcc version 2.7-97r2aBeta * * The Cygnus B18 (gcc version cygnus-2.7.2-970404) release did not * exhibit this behavior. * * Tom Uban - 17 March 1998 * uban AT netnitco DOT net */ unsigned short foobar = 1; main() { unsigned short *sptr = &foobar; unsigned long cksum; int i; cksum = 0; for (i = 0; i < 4; i++) cksum += *sptr; printf("%d\n", cksum); } - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".