On Tue, Sep 04, 2007 at 11:29:46PM -0500, Rob Landley wrote: > and there's defined behavior for > and < too.
You sure about that? All of the defined uses of > and < on pointers in 6.5.8 require the two pointers to point to the same actual object (or one past the same object in the case of an array). A null pointer doesn't satisfy those cases, and "In all other cases, the behavior is undefined". 6.5.9 has special wording allowing != and == to apply to null pointers. Interestingly, this means: NULL == NULL defined NULL <= NULL undefined Of course it's possible I'm missing wording elsewhere that makes null pointers work. As you say, the Standard can be difficult to work with. Just trying to support things like while(p) or (p && ...) where p is a pointer is tricky because: - They test if the expression p "compares equal with 0", - A pointer can only be compared with 0 if that 0 is a null pointer constant. - A 0 is only a null pointer constant if it's a constant integer expression. - I see nothing that _explicitly_ states that the _implicit_ 0 being compared against is a constant integer expression. Hmmm. -Dave Dodge _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/tinycc-devel