tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] [PATCH] Preprocessor: ignore everything after #error


From: Dave Dodge
Subject: Re: [Tinycc-devel] [PATCH] Preprocessor: ignore everything after #error or #warning
Date: Tue, 25 Sep 2007 04:41:42 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

On Tue, Sep 25, 2007 at 09:58:03AM +0200, Marc Andre Tanner wrote:
> Dave Dodge wrote:
> >The real problem here seems to be that a bare apostrophe can be a valid
> >preprocessing token according to C99,
> 
> Ok i took a look at the C99 draft link which you posted and found the
> following in 6.4 #3:
[...]
>  and single non-white-space characters that do not lexically match
>  the other preprocessing token categories.58) If a ' or a "
>  character matches the last category, the behavior is undefined.
> 
> I am not quite sure whether i have understood the above but doesn't it 
> say that the behavior of a ' in this context is undefined?

You're right.  I missed that caveat about single quotes being
undefined.  I'd mainly looked at the grammar in Annex A, which simply
says "each non-white-space character that cannot be one of the above"
and doesn't bother to mention quotes as a special case.

So the _real_ problem is that the C code you're processing has
undefined behavior ;-)

You could argue that since the line in question is #ifdef'd out, the
token shouldn't be a problem.  But going strictly by the Standard you
get the undefined behavior as early as translation phase 3 when the
tokenization takes place, and the #ifdef doesn't get handled until
phase 4.

Note that the bare apostrophe probably also wreaks havoc with syntax
highlighting editors.  Emacs 21.4 seems to get very confused by it.

                                                  -Dave Dodge




reply via email to

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