The importance of showing ALL of the code in C

From: Fred Cisin <cisin_at_xenosoft.com>
Date: Thu Feb 7 14:53:24 2002

On Thu, 7 Feb 2002, Ethan Dicks wrote:
> --- Sean 'Captain Napalm' Conner <spc_at_conman.org> wrote:
> > It was thus said that the Great "Fred Cisin (XenoSoft)" once stated:
> > C allows the *pointer* to exceed the limit by one element, but not to
> > *dereference* said pointer.
> > -spc (Well, dereferencing such a behavior invokes (I think) undefined
> > behavior)
> Exactly, but "undefined behavior" is not the same thing as illegal.

I agree. Even "stupid and suicidal" is not the same thing as illegal
IN C!


Folks,
PLEASE be careful about attribution!
The above quotes falsely attributes to me a statement that an "out of
range" pointer can not be dereferenced. I did NOT say that! C has no
objections to dereferencing pointers to garbage. You can put ANY RANDOM
bit pattern into a pointer variable, and get garbage out.

There is a presumption in many of these posts that "stupid and suicidal"
is the same as illegal.
C has NO compunctions about permitting you to do things that you really
shouldn't do!
If you want to say that one should NEVER do something, that's fine; but do
NOT say that it is "illegal" in C.
Non-portable assumptions are NOT illegal. Stupid, yes; but NOT illegal.

A REAL C compiler does NOT have array bounds checking!
Nor do any C compilers that are on-topic for this list.

It certainly might be true that MICROS~1 might currently sell compilers
that might protect you from your mistakes, or wrap you and your program in
a safe cocoon, but that is contrary to the fundamental spirit of C.
Even ANSI C does not adhere to K&R's basic spirit of C.
It is one (of many) reasons why C is NOT necessarily the right language to
use for some projects.

"If you want to shoot yourself in the foot,
a REAL C compiler will provide you with unlimited ammunition."

--
Grumpy Ol' Fred        cisin_at_xenosoft.com
Received on Thu Feb 07 2002 - 14:53:24 GMT

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:34:45 BST