references to dereferenced null pointers
Boyd Roberts
boyd at necisa.ho.necisa.oz
Tue Mar 20 09:53:59 AEST 1990
In article <945 at ns-mx.uiowa.edu> williams at 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 at necisa.ho.necisa.oz.au
``When the going gets wierd, the weird turn pro...''
More information about the Comp.lang.c
mailing list