This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Varargs macros subtly broken
- To: gcc at gcc dot gnu dot org
- Subject: Re: Varargs macros subtly broken
- From: Neil Booth <NeilB at earthling dot net>
- Date: Mon, 25 Sep 2000 22:30:47 +0100
Hi Jamie,
Thanks for the bug reports.
> Observe: gnu_count expansions differ.
Yes, this is a bug with identifying empty varargs (the VOID_REST
flag). I'm bootstrapping a patch to fix this at the moment; I've got
rid of the VOID_REST stuff as it was too ugly to fix, and am trying
something else instead.
> gnu_index makes preprocessing fail.
Those macros are, um, let's just say deep and complicated. I'll try
and look into it when I've got time; it would take me ages just to
figure out what's supposed to be going on, never mind what actually
is.
> Bonus observations:
>
> - ## swallows the token in rest arg macros, even with
> __VA_ARGS__. According to the CPP manual, this is an
> unreliable feature that is deprecated, and it's use is warned
> about. Actually there is no warning. As you can see from
> this code, that feature is essential, though only when the
> discarded token is ",", to get the correct results here. Can
> we have a decision to not deprecate it at least in the comma
> case, provided that is compatible with ISO C99? (Presumably
> ISO C99 doesn't define the behaviour of pasting "," before
> another token anyway -- leaving a loophole which GCC can
> exploit to discard it).
I do believe that what you describe is what Zack intended. If he
concurs, I'll update the docs. I think you only get a pedantic warning,
and then only if using std=c99. Maybe that should be changed.
> - The output has spurious newlines, followed by a corrective "#
> LINE" directive.
As you've noticed in your other bug report, the output code is a mess.
I'm splitting it out to a separate file soon, to get all that code in
one place. Hopefully it won't be too hard to clean up. I think
there's an outstanding bug report about #pragma's causing similar
problems. I suspect it's all the same problem.
Neil.