This error was similar to bug #20185, but now it is a C-Programm and not C++
// Postet by [EMAIL PROTECTED] // Compiler Error found: // gcc (GCC) 3.3.4 (pre 3.3.5 20040809) // under SuSE Linux kernel 2.6.8-24.10-default (i386) // // This Bug is a little bit different in relation to bug #20184 // // If this littel programm is compiled with the option -O2 // the assignment in the inline function was wrong. // If I remove the 'inline' of any of both functions the result is correct. // // Compiled with: gcc -Wall error.cpp // -> OK, last line of printout: 0000000000000001 // // Compiled with: gcc -Wall -O2 error.cpp // -> ERROR, last line of printout: 080482c500000001 // // Compiled with: gcc -Wall -O2 error.cpp // but without 'inline' for GenData() and/or GetData() // -> OK, last line of printout: 0000000000000001 // #include <stdlib.h> #include <stdio.h> typedef unsigned int uint32; typedef unsigned long long uint64; struct data { uint32 lo; uint32 hi; }; inline struct data * GenData ( struct data * d, uint32 num ) { d->lo = num; d->hi = -(num<0); return d; } inline uint64 GetData ( const struct data * d ) { return *(uint64*)&d->lo; } int main ( int argc, char ** argv ) { printf("sizeof(uint32)=%d\n",sizeof(uint32)); printf("sizeof(uint64)=%d\n",sizeof(uint64)); printf("sizeof(data)= %d\n",sizeof(struct data)); uint32 tab[] = { 1,1,1,1,1 }; uint32 *p = tab; struct data D; printf("D=%p lo=%p hi=%p\n",&D,&D.lo,&D.hi); uint64 u64 = GetData(GenData(&D,*p++)); printf("%016llx\n",u64); return 0; } -- Summary: assignment error in inline function Product: gcc Version: 3.3.4 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dirk at cle-mens dot de CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20189