This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Optimizer Bug with gcc-2.95 on Solaris-(2.6|7)
- To: gcc-bugs at gcc dot gnu dot org, bug-gcc at gnu dot org
- Subject: Optimizer Bug with gcc-2.95 on Solaris-(2.6|7)
- From: Jürgen Zimmermann <jnzimmer at informatik dot uni-kl dot de>
- Date: Wed, 18 Aug 1999 09:35:54 +0200
- Organization: University of Kaiserslautern, Germany
The following code was found in a Linux Usenet-group, but it turned out,
that gcc-2.95 on Solaris-2.6 and
Solaris-7 shows the same behaviour.
CFLAGS="" and CFLAGS="-O3" produce correct results,
CFLAGS="-O" or CFLAGS="-O2" produce false results.
The code is:
#include <stdio.h>
/* If one=1, then the output should be: bit&1 */
unsigned test(unsigned one , unsigned bit)
{
unsigned val= bit & 1;
unsigned zero= one >> 1;
val++;
return zero + ( val>> 1 );
}
int main()
{
printf("ret=%d\n", test(1,0)); /* should print 0 */
printf("ret=%d\n", test(1,1)); /* should print 1 */
printf("ret=%d\n", test(1,65535)); /* should print 1 */
return 0;
}
So long,
Juergen Zimmermann
-------------------------------------------------------------------------
Jrgen Zimmermann Department of Computer
Science
jnzimmer@informatik.uni-kl.de University of Kaiserslautern
Phone: +49 631 205 3280 P.O. Box 3049
Fax: +49 631 205 3299 67653 Kaiserslautern, Germany
WWW: http://www.uni-kl.de/AG-Haerder/Zimmermann/
-------------------------------------------------------------------------