This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Possible variadic macro bug
[Get raw message]
On Tue, Nov 13, 2001 at 10:21:47PM +0000, Neil Booth wrote:
>
> I agree with Clive Feather's point that the use of ## is ugly because
> it gives 2 meanings to ##; I said as much over a year ago when this
> was discussed. So I'm in favour of a clean replacement. I didn't
> like any of his three suggestions at all, though.
Do you have a reference to what he said?
> > The reason I ask is that a couple of people have objected to the
> > ", ##" as being ugly (which I grudgingly grant that it is), and it
> > seems to me that the above change cannot break any currently-
> > conforming code, and always does what the user meant. The formal
> > wording would state that a comma preceeding __VA_ARGS__ is omitted
> > if __VA_ARGS__ is empty. I don't think anyone ever wants the
> > comma in that case.
>
> It might work. I suspect it could, however, break some nested macro
> expansions where the nesting macro was expecting an empty argument.
> There are some really obscene uses of varargs macros floating around.
> testsuite/gcc.dg/cpp/macro{3,8}.c and vararg{1,2}.c look like
> candidates for something to go wrong. [And if you want a truly mind-
> boggling example of abuse of varargs macros, check out vararg2.c!].
> But, at a glance, they seem like they would still be OK.
>
> If GCC passed its existing testsuite without regresssions with this
> modification, I'd be quite happy to make it permanent, as the existing
> tests cover macro expansion very thoroughly. We could then deprecate
> the existing kludges. I can't speak for Zack, though.
I agree with Neil: I can imagine there being hairy nested macro
expansions where this behavior would break something. If we can't
find any, however, I have no objection to the alternative proposal.
",##" is known to work in a lot of production code and is therefore
the safer move - but it is indeed ugly. I don't think it is
particularly _confusing_, though; commas can't be token-pasted with
anything, so the notation is unambiguous.
zw
p.s. I have a lot of work this week, but I'll try to get you the draft
DRs by Monday.