Xref: news2.mv.net comp.os.msdos.djgpp:2663 From: jan AT stack DOT urc DOT tue DOT nl (Jan Oonk) Newsgroups: comp.os.msdos.djgpp Subject: Compile bug? Date: 12 Apr 1996 16:03:09 +0200 Organization: MCGV Stack, Eindhoven University of Technology, the Netherlands. Lines: 68 Message-ID: <4klnqt$pes@toad.stack.urc.tue.nl> NNTP-Posting-Host: toad.stack.urc.tue.nl To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi! Here's a short testprogram to show a compile bug(???) or my mistake :) #include struct TInfo{ int v0; int v1; }; void Proc(TInfo *p) { putchar(p->v1); } inline void Proc2(TInfo *p) { asm volatile ("movl %0,%%eax \n" "movl 4(%%eax),%%eax \n" "pushl %%eax \n" "call _putchar \n" : : "g" (p) : "eax"); } inline void Proc3(int v1) { asm volatile ("movl %0,%%eax \n" "pushl %%eax \n" "call _putchar \n" : : "g" (v1) : "eax"); } int main(void) { TInfo Info; TInfo *PInfo; PInfo=&Info; PInfo->v1=1; //Works with -O0 and -O2 Proc(PInfo); PInfo->v1=2; Proc(PInfo); //Following line is "removed"/optimized out by DJGPP with -O2 compileoption PInfo->v1=1; //Only works in -O0 !! ???? and NOT in -O2 Proc2(PInfo); PInfo->v1=2; Proc2(PInfo); PInfo->v1=1; //Works with -O0 and -O2 Proc3(PInfo->v1); PInfo->v1=2; Proc3(PInfo->v1); return 0; } I debugged it and it the PInfo->v1=1 is removed(optimized out) by the compiler...! Can anyone please help me to point out (no doubt) my mistake! Thanks in advance, A not so experienced C/C++/DJGPP programmer :) -- This message was sent by Trax/SPiRiT! Please EMAIL all replys to Jan AT stack DOT urc DOT tue DOT nl