From: paulm-nospam@visix.com
Subject: Digital Unix 4.0 C compiler bug.
Date: 1997/12/05 [thread overview]
Message-ID: <u67p361ik.fsf@visix.com> (raw)
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 <stdio.h>
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
reply other threads:[~1997-12-05 5:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox