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]
Other format: [Raw text]

bug report 20020719


Originator

dylan

Synopsis

compile with -O2 has some wrong results.

Severity

serious

Priority

medium

Category

optimization

Class

sw-bug

Release

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98).


Environment

RedHat Linux v7.2, kernel version 2.4.7-10 i686.

Description

when i compile with command "gcc -Wall example.c",  the executing result is
what i want.

when i compile with command "gcc -Wall -O2 example.c", executing result is
wrong.

compile with "-O0", "-O1" are OK.

How-To-Repeat

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
        unsigned char temp[4] = {0x10, 0x80, 0, 0};
        unsigned short *sptr, sdata;

        sptr = (unsigned short *)temp;

        sdata = *sptr;
        printf("*sptr = %x\n", *sptr);
        printf("sdata = %x %x\n", (sdata>>8)&0xff, sdata&0xff);

        return 0;
}

Fix

No.

+---------------------------------------------------------
  dylan@sd.liteonit.com.tw


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