Article View: comp.arch
Article #13023Re: catering to bad code
From: zs01#
Date: Fri, 20 Feb 1987 02:46
Date: Fri, 20 Feb 1987 02:46
40 lines
2488 bytes
2488 bytes
I think compilers and operating systems should go out of their way to punish
bad code. Things like unmapping the zero page, and initializing the stack
with something other than 0s are good examples of what I have in mind. Bad
code is due to one of two things, either the programmer is being lazy, or
he/she just didn't know about it. In the latter case, I am sure that the
programmer would prefer to know he/she screwed up instead of letting somebody
else find out about it. Even more important is the fact that a lot of this
"bad code" is flaky and a genuine pain to debug, regardless of the issue of
portability.
As an example, indirecting a NULL function pointer on an IBM RT will
effectively jump to the main() function of your program. Because of this, we
had a lot of fun one day trying to figure out why a certain program was
"infinitely tail-recursive". Indirecting a NULL pointer is likely to be an
unintentional error. Giving the guy a 0 just means that it will take longer
to find the bug.
Another bug I have seen twice in the last week is the following:
struct foo *InitFoo()
{
register struct foo *tempFoo = (struct foo *) malloc(sizeof(struct foo));
tempFoo->bar = 1;
tempFoo->bletch = 2;
tempFoo->baz = "loselose";
}
Notice there is no return statement there! Surprisingly, this code will work
on a lot of machines. The compiler wisely decides that it can use the return
register as a temporary (since there is no return value).
Sincerely,
Zalman Stern
Information Technology Center
Carnegie Mellon
(ARPA) zs01#@andrew.cmu.edu
(UUCP) try something like
...seismo!rochester!pt.cs.cmu.edu!andrew.cmu.edu!zs01#
Technical Details
Message-ID:
<MS.V3.18.zs01.80021e08.leola.ibm032.294.0@andrew.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!bacchus!husc6!seismo!rochester!pt.cs.cmu.edu!andrew.cmu.edu!zs01#Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!bacchus!husc6!seismo!rochester!pt.cs.cmu.edu!andrew.cmu.edu!zs01# From: zs01#@andrew.cmu.edu.UUCP Newsgroups: comp.arch Subject: Re: catering to bad code Message-ID: <MS.V3.18.zs01.80021e08.leola.ibm032.294.0@andrew.cmu.edu> Date: Thu, 19-Feb-87 21:46:43 EST Article-I.D.: andrew.MS.V3.18.zs01.80021e08.leola.ibm032.294.0 Posted: Thu Feb 19 21:46:43 1987 Date-Received: Sat, 21-Feb-87 04:15:19 EST Organization: Carnegie-Mellon University Lines: 40 ReSent-Date: Thu, 19 Feb 87 21:48:18 est ReSent-From: postman#@andrew.cmu.edu ReSent-To: nntp-xmit#@andrew.cmu.edu Return-path: <zs01#@andrew.cmu.edu> To: outnews#ext.nn.comp.arch@andrew.cmu.edu Newsgroup: comp.arch