From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,fe87821bf91049ec,start X-Google-Attributes: gidfee84,public From: paulm-nospam@visix.com Subject: Digital Unix 4.0 C compiler bug. Date: 1997/12/05 Message-ID: #1/1 X-Deja-AN: 295546354 Organization: Visix Software Inc. Reply-To: paulm-nospam@visix.com Newsgroups: comp.unix.osf.osf1 I found a problem with the Digital Unix 4.0's C compiler. When compiled optimized (i.e. "-O") functions don't properly return structures. The following example program should show the problem: #include typedef struct junkType { long var1; long var2; long junk1; long junk2; long junk3; long junk4; long junk5; long junk6; long junk7; } junkType; junkType foo(int x, int y) { junkType j; j.var1 = x; j.var2 = y; return j; } void foo2(junkType jt1, junkType jt2) { printf("Size of junkType is: %d bytes.\n\n", sizeof(junkType)); printf(" %d %d %d %d \n", jt1.var1, jt1.var2, jt2.var1, jt2.var2); } main(int argc, char **argv) { foo2(foo(1, 2), foo(3, 4)); } The above program outputs "3 4 3 4", instead of "1 2 3 4". Is this a known problem? Is there a list of known compiler bugs somewhere? System info: >> cc -V DEC C V5.2-033 on Digital UNIX V4.0 (Rev. 564) /usr/lib/cmplrs/cc/ld: >> uname -a OSF1 f18.visix.com V4.0 564 alpha p.s. I know it's considered "bad form" to return a structure, but I believe it is legal ANSI. (It's not my code). -- paulm-nospam@visix.com