Hello , this code below compiles with different results. with -O0 the result is 1.(expected res.) from -O2 (and above) the result is 0.(BUG!)
Thank You ! include<stdio.h> #ifdef _BIG_ENDIAN #define FP_SEG(fp) (*((unsigned short*)&(fp))) #define FP_OFF(fp) (*((unsigned short*)&(fp)+1)) #else #define FP_SEG(fp) (*((unsigned short*)&(fp)+1)) #define FP_OFF(fp) (*((unsigned short*)&(fp))) #endif #define BYTE unsigned char #define _huge unsigned short int zHugeOffset; int main(){ BYTE _huge *phb; unsigned short int selBit; FP_SEG(phb)=0; FP_OFF(phb)=0xffff; phb+=0x8000; selBit=FP_SEG(phb); zHugeOffset=selBit; printf("RESULT :%hd\n", zHugeOffset); } -- Summary: Bad code generation with O3 Product: gcc Version: 4.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tompa-l at prolan dot hu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33379