Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!mcnc!rti-sel!dg_rtp!meissner
From: meissner@dg_rtp.UUCP (Michael Meissner)
Newsgroups: comp.lang.c
Subject: Re: structure function returns -- how?
Message-ID: <782@dg_rtp.UUCP>
Date: Thu, 1-Jan-87 14:16:31 EST
Article-I.D.: dg_rtp.782
Posted: Thu Jan  1 14:16:31 1987
Date-Received: Thu, 1-Jan-87 22:27:31 EST
References: <131@hcx1.UUCP> <773@maynard.BSW.COM> <7403@utzoo.UUCP> <490@aw.sei.cmu.edu.sei.cmu.edu> <326@bms-at.UUCP> <5076@ism780c.UUCP>
Reply-To: meissner@dg_rtp.UUCP (Michael Meissner)
Organization: Data General (Languages @ Research Triangle Park, NC.)
Lines: 26

In article <5076@ism780c.UUCP> tim@ism780c.UUCP (Tim Smith) writes:
>
>If the called function does the copying, then the following can
>cause problems:
>        struct SpanishInquisition nobody, expected();
>
>        nobody = expected();
>        expected();
>
>How does expected() tell these two cases apart?  If it doesn't, then
>it is going to blow away something when it tries to copy back a structure
>in the second call.
>
>I suppose the compiler could note that the return value is being ignored,
>and pass a pointer to some temporary place to hold the ignored return
>value, but that seems kind of ugly.

If the compiler returns structures by having the caller pass a pointer to
an area that is copied into, then for the second example, the compiler does
have to create a temporary (preferably a stack temp...) and pass it's pointer.
If it doesn't, the compiler has an undocumented feature (ie, bug) and it
should be fixed.  BTW, the Data General compiler does return structures in
this manner, and yes we do pass the address of a temporary in an accumulator.
-- 
	Michael Meissner, Data General
	...mcnc!rti-sel!dg_rtp!meissner