Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Digital Unix 4.0 C compiler bug.
@ 1997-12-05  5:00 paulm-nospam
  0 siblings, 0 replies; only message in thread
From: paulm-nospam @ 1997-12-05  5:00 UTC (permalink / 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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-12-05  5:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-12-05  5:00 Digital Unix 4.0 C compiler bug paulm-nospam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox