Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!samsung!cs.utexas.edu!asuvax!ncar!ames!uhccux!munnari.oz.au!cluster!necisa!boyd From: boyd@necisa.ho.necisa.oz (Boyd Roberts) Newsgroups: comp.lang.c Subject: Re: references to dereferenced null pointers Message-ID: <1243@necisa.ho.necisa.oz> Date: 19 Mar 90 23:53:59 GMT References: <51083@microsoft.UUCP> <25EB8EE8.8462@paris.ics.uci.edu> <1990Mar12.175613.12082@utzoo.uucp> <1623@argus.UUCP> <1990Mar14.164539.23685@utzoo.uucp> <16179@haddock.ima.isc.com> <945@ns-mx.uiowa.edu> Organization: NEC Information Systems Australia Pty. Ltd. Lines: 32 In article <945@ns-mx.uiowa.edu> williams@umaxc.weeg.uiowa.edu.UUCP (Kent Williams) writes: > >To muddy the waters further, It isn't uncommon (and not terribly >unportable) to use a set of small integral constants, say 0 .. 10 as >sentinel values assigned to pointers, e.g. > > switch((int)ptr) { > case 0: do0(); break; > case 1: do1(); break; > . > . > . > default: > it_really_is_a_pointer(ptr); > } > Have you _completely_ lost your marbles? The above is one of the most disgusting and unportable constructs I've ever seen. How do you know what integer representations a pointer may have, unless you know the target machine's architecture? This sort of language abuse is sure to lay traps that will be sprung when least expected. Such code would probably pass most acceptance tests, but would fail catastrophically at some later time. Do you really find it acceptable to write code that has such potential for failure? Boyd Roberts boyd@necisa.ho.necisa.oz.au ``When the going gets wierd, the weird turn pro...''