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]

Optimization Bug with gcc 2.95.1


There seems to be a optimization bug in gcc 2.95.1.

For instance the following program does not get the same
results
with -O (or -O2) and -O3 (or nothing).

-- Attila

#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;
}




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