Macro expansion bug in gcc?

Zack Weinberg zack@wolery.cumb.org
Mon Jun 19 09:09:00 GMT 2000


On Mon, Jun 19, 2000 at 09:53:55PM +0900, Neil Booth wrote:
> The following test case appears as gcc.dg/200000209-2.c
> 
> #define NO_PAREN(rest...) rest
> #define DEFINE_CATEGORY(category, items) \
> const int _nl_value_type_##category[] = { NO_PAREN items }
> 
> DEFINE_CATEGORY
> (
>  LC_COLLATE,
>  (
>    1,
>    2,
>    3,
>   ));

Hm.  Ignore the const int _nl_value_type_##category[] = bit for now.
The first pass gives us

 { <NO_PAREN> <ARG ( 1 , 2 , 3 )> }

There are no macros to be expanded within the argument, so we proceed
to expand the expansion.  NO_PAREN is encountered, is not disabled,
and the next token is an open paren, so it's in function context.  So
it is to be expanded.  'rest' is a vararg parameter, it absorbs all
three actual parameters.

You presumably disagree about the context seen by NO_PAREN.  Could you
explain why you think it is not to be expanded?

zw


More information about the Gcc-bugs mailing list