Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!oracle!news From: gstein@oracle.com (Greg Stein) Newsgroups: comp.sys.mac.programmer Subject: Re: MPW compiler bugs (was: interface war) Message-ID: <1990Feb14.004350.14475@oracle.com> Date: 14 Feb 90 00:43:50 GMT Sender: news@oracle.com Reply-To: gstein@oracle.com (Greg Stein) Organization: Oracle Corporation, Belmont, CA Lines: 68 > From: jln@acns.nwu.edu (John Norstad) > In article <1046@watserv1.waterloo.edu> bmwrkshp@watserv1.waterloo.edu ( > Wrkshp Id - Sys Design ) writes: > > But I'm sure THINK C is still an order of magnitude > > faster. Don't know what that linker is doing. Sure takes its own > > sweet time even on Mac II's. > > As I understand it, one of the reasons is that MPW's linker is much > smarter. For example, it lets you direct individual routines within a > single module to different segments, and it eliminates dead code. I'm not > sure about all this, though. > > > I would probably use MPW 99% of the time if it weren't for the fact > > that the C compiler is broken. Even the updated C compiler > > included with the C++ package still has bugs. > > I've heard this from other places too (e.g., the guys at Wolfram). But > I'm up to 16,000 lines of pretty hairy C code in Disinfectant now, and > I've yet to encounter a single compiler bug. Maybe because I'm a reformed > Pascal fanatic, I don't write as ugly code as the rest of you guys :-) > > John Norstad > Northwestern University > jln@acns.nwu.edu > I have a nice bug from V3.1b3e19 of MPW C. Type in this little code fragment, compile it, and look at its output: int main() { char *a, *b = 0L; int c = 0L; /* assignment to prevent warnings */ if (a = &b[c]) return(1); return(2); } The relevant part is this: ... LEA $00(A3,D7.L),A4 ; all vars are in registers BEQ.S @1 ... Note that a conditional branch is performed without any testing being done. (Yes, the bug has been reported to Apple) Don't ask me how I found the bug, but it is repeatable. Things like this make me wonder just how stable the compiler is. I realize that I have a Beta version and that the line of code above is sheer idiocy for most purposes, but still... John, I will agree with you, though, about the Linker. Think C includes code a whole file at a time -- it won't pick out individual routines from a file. MPW C will do this. What I don't get is why Think C hasn't changed this by now -- they've had a few versions to do it. Heck, in high school when I wrote the Rascal compiler for the Mac, I wrote a linker that did dead code analysis and picked out a routine at a time. Surely, Mike Kahl could do it. Well, John, I don't know whether you write ugly code or not, but Disinfectant 1.6 is a very nice piece of work. Thanx. Greg Stein -- This posting bears no relation to my employer Arpa: gstein%oracle.uucp@apple.com UUCP: ..!{uunet,apple}!oracle!gstein