pointers is pointers (a cautionary tale)

Wayne Throop throopw at sheol.UUCP
Wed Aug 29 09:00:16 AEST 1990


> From: meissner at osf.org (Michael Meissner)
> C programmers are notorious for thinking that all pointers look the
> same.  I had to put in several options
> [..into the DG MV Eclipse C compiler..] to either flag when one type of
> pointer was used in the wrong context, or silently add extra
> instructions so that programmers who were too lazy to type things
> correctly could get their programs to work.

And even these heroic efforts would not save the proud, scarce,
and noble band of siblings who were trying to port code to this
class of machine from those C coders out there who were actively
perverse in their faith in the pointerness of pointers.

I recall one time when I had employed all the checks that Michael had
implemented, and STILL pointers ended up in the wrong format with no
warning.  Eventually, it was discovered that this particular piece of
cr...  uh, code deliberately and with malice aforethought declared some
pointer externals to be type (struct foo*) in some modules and (char *)
in others.  (I say we found this "eventually".  Lint would have found it
immediately, of course, but the original coders had done
something-or-other to cloud lint's mind on the matter.  Never did get
that sucker running on the MV, as I recall, though it consumed many a
CPU cycle on Vaxen the world over.)

( If I were to try porting it today, I'd probably take to calling
  the program "Bo".  You know.  "Bo knows pointer format."
  "Bo knows endianness."   "Bo knows stack direction."
  "Bo knows the linker algorithm."  "Bo knows int == long."
  And so on, ad nauseam. )

Like they say, what programers don't know ain't the problem.
It's all them things they DO know that jest ain't SO.
--
Wayne Throop <backbone>!mcnc!rti!sheol!throopw or sheol!throopw at rti.rti.org



More information about the Comp.lang.c mailing list