tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Fun little bug...


From: Dave Dodge
Subject: Re: [Tinycc-devel] Fun little bug...
Date: Wed, 5 Sep 2007 01:30:42 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]