lint, pointers, 0 (what else?)

Bill Shannon shannon at sun.uucp
Fri Feb 8 16:59:15 AEST 1985


> Also, another point on type-correctness: even on a Motorola 68000
> implementation with 32-bit "int"s, you can lose if you don't declare
> functions which return pointers.  See the article in the Dallas USENIX
> proceedings by the people from Motorola on the System V microport.
> The AT&T compiler (and, I'm told, the Sun compiler), put the return
> value of pointer-valued functions in A0 - NOT in D0.  As such, if you don't
> declare "malloc" as returning "char *", its caller will expect the return
> value to be in D0 and will get whatever junk was there last.

The real world is a tough place to live.  We decided we could not afford
to break all the programs written by lazy programmers so even pointer-
valued functions return their result in D0.

Also, we once optimized procedure call/return in such a way that it was
impossible to implement alloca (allocate memory on the stack of the
current procedure, very useful but EXTREMELY implementation dependent).
We also had to remove that as a concession to reality.

Of course, you've never really had lint problems unless you've had to
deal with a word adressed, 24-bit word machine on which

	int i; char *p; p = (char *)&i;

generates more than a simple move instruction!

					Bill Shannon
					Sun Microsystems, Inc.



More information about the Comp.lang.c mailing list