Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!ll-xn!mit-eddie!bloom-beacon!athena.mit.edu!peter From: peter@athena.mit.edu (Peter J Desnoyers) Newsgroups: comp.arch Subject: Re: Bad RISC Message-ID: <3406@bloom-beacon.MIT.EDU> Date: 2 Mar 88 17:55:24 GMT References: <216@wsccs.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: peter@athena.mit.edu (Peter J Desnoyers) Organization: Massachusetts Institute of Technology Lines: 33 Keywords: SUN RISC Summary: sign extension a bug??? The main complaints we seem to have heard about the C compiler for the SUN 4 are: 1) it sign-extends characters passed as arguments. This is, I believe, required by K&R, so it better do so. The problem that bites everyone is whether the type being used is 'unsigned char' or signed 'char' - you don't always have a choice. Any code that relies on the existence of unsigned/signed chars or longs, especially when it is careless about specifying their signedness, is a definite lose on a lot of machines. (I assume it would be a lose on many RISC's, as it loses on an awful lot of CISC, byte-addressing machines.) 2) it doesn't handle return values where the type is 'resolved' by the linker. I have never worked with a C compiler, to my knowledge, which runs any passes after the linker to incorporate these 'resolved' types :-). I can see two problems here - (1) the compiler is paranoid and wants type information to ensure that the value is aligned. Then the compiler is not source-code compatible with the Sun 3 one, even though it's the fault of Sun and not their Sparc chip. (2) you are returning a non-aligned value at runtime - then your code is WRONG, and shouldn't have worked on the Sun 3, either. I think the problem here may be some people (like you said, your boss had more problems than you did) who have spent most of their time working on one machine, and have never seen how to fix a portability problem like characters getting sign-extended. It is compounded by the fact that Sun probably did not make their compiler source-code compatible, when except for unportable code, they could have. (At the cost of more run-time crashes while debugging) Take heart, though - at least you got newer and faster machines in return for all this B.S. Some people have had to go through this just for a new operating system release. Peter Desnoyers