This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug report 20020719
- From: "dylan" <dylan at sd dot liteonit dot com dot tw>
- To: <gcc-bugs at gcc dot gnu dot org>
- Date: Fri, 19 Jul 2002 15:52:50 +0800
- Subject: 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