fix cpp segmentation fault with perverse input

Zack Weinberg zack@wolery.cumb.org
Wed Feb 2 14:06:00 GMT 2000


On Wed, Feb 02, 2000 at 04:51:59PM -0500, Dave Brolley wrote:
> Why discard them? I would prefer for cpp to just treat them as
> ordinary pp-tokens and keep them as part of the argument.
> Consider:
> 
> #define foo(a) #a
> char *s = foo( blah
> #undef foo
>      blah );
> 
> The result would then be
> 
> char *s = "blah #undef foo blah";
>
> 
> IMHO, it's not cpp's job to try and clean up incorrect code for
> the benefit of the compiler.

Two reasons.  First, if the directive had been executed it would have
disappeared from the output, so this is marginally more consistent.
Second, this is a hard error.  The code is being rejected, and we want
to tune the semantics for better error detection later on.

zw



More information about the Gcc-patches mailing list