Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.lang.c++
Subject: Re: RETBUG in cfront. Passing/Returning Class Instances.
Message-ID: <4873@mimsy.UUCP>
Date: Sun, 21-Dec-86 19:43:31 EST
Article-I.D.: mimsy.4873
Posted: Sun Dec 21 19:43:31 1986
Date-Received: Mon, 22-Dec-86 23:26:05 EST
References: <59@otc.OZ> <213@crys.WISC.EDU>
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 42

In article <213@crys.WISC.EDU> solomon@crys.WISC.EDU (Marvin Solomon) writes:
>... cfront contains an option (turned on in the default version)
>to generate code to get around a C compiler bug. ...

>Unfortunately, the bug may be present even if [a previously posted
>test] program compiles and runs "correctly".  The Berkeley 4.3 UNIX
>compiler for the VAX (as well as the 4.3beta and, I suspect, all
>earlier compliers) generates incorrect code, but the incorrect
>code is harmless.

Sometimes!  It depends on whatever happens to be in r0.  E.g.,

	struct foo { int f; };
	struct foo f() { g(); return; }
	int g() { return (0xc0000000); }
	main() { f(); exit(0); }

will crash.

>Here is the modified test program:
>	struct Crap { int i; };
>	struct Crap f(cp,ip)
>	struct Crap *cp;
>	int *ip;
>	{
>	cp->i = (*ip)++;
>	return;
>	}

This program does indeed point out a bug in the 4.3BSD compiler
(and in lint, which does not complain), but the code itself is
wrong as well.  The function is declared to return an object of
type `struct Crap'; all the paths out of this function must return
such an object.  For example,

	return (*cp);

would be correct.  `return;' is not, nor is falling off the end
of the function without a `return'.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!mimsy!chris	ARPA/CSNet:	chris@mimsy.umd.edu