gEDA-dev: gEDA-user: What to do with some bugs?
DJ Delorie
dj at delorie.com
Mon Apr 28 01:49:07 EDT 2008
> You appear to be reading the first sentence as being "a null pointer
> constant is some implementation-defined (or undefined) thing, which
> might be an integer constant expression with value 0, or might be such
> an expression cast to void *, or might be something else entirely".
The standard explicitly says that "NULL" is implementation defined.
It also says it is a null pointer constant. It does not say it must
expand to the token "0".
[again, that doesn't stop an implementation from doing so even when
it's a bad idea]
So, I ask again - do you know of any platforms which we care about,
where you can't pass NULL to ... and have it work as expected?
> I'm reading it as "`null pointer constant' means anything that fits
> either [description A] or [description B]", as in "a father, or a
> mother, is called a parent".
That would be the converse to what is said in the standard, and not
guaranteed to be true. Just because A is a B doesn't mean that B is
an A.
Consider (in your example) that there are other things which may be
parents (think "legal guardians"), and the word "mother" may not
always mean a parent (think motherboard, or mother-of-pearl).
> For what it may be worth, K&Rv2 seems to be closer to my
> interpretation than yours (page 102 says unadorned zero converts to
> a null pointer,
Not in something like "f += 0;" where f is type "float".
> However, your reading calls into question significant portions of the
> rest of the standard; for example, 6.3.2.1.1 says "An lvalue is an
> expression with an object type or an incomplete type other than void" -
> does this mean that an lvalue is one or the other of those or perhaps
> some third thing, and the implementation gets to pick which one?
No, it means that an lvalue is one of those things. You're confusing
the logic; the above statement is completely different than the NPC
case. The above is: An A is C or D. The NPC case is: C or D is an A.
Just because these statements are true, does not mean their converses
are true. Their contrapositives are true, though.
If you read "A or B must be foo" and later "C must be foo", it doesn't
imply that C must be A or B. They could be members-of-sets, not
equalities. Example: either 4 or 5 is an integer. That doesn't mean
that all integers are 4 or 5. "Red is a color" doesn't imply that all
colors are red. "Red is the color" does (for that statement's
context).
> >> NULL *is* a "null pointer constant" in all contexts.
> > But the value 0 is NOT a null pointer constant in all contexts.
>
> I believe it is, in that I see it as fitting the definition: it is "an
> integer constant expression with value 0, or [something else]".
Again, that clause is in the context of conversions to pointers. If
you're converting to pointer, "0" is a NPC. If you are not converting
to pointer, 0 might not be a NPC.
> > And before we start throwing qualifications around... I'm [...]
>
> Was I throwing qualifications around? I didn't think so.
I said *before* we start throwing :-)
More information about the geda-dev
mailing list