This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug preprocessor/61613] ,##__VA_ARGS__ fails to expand the first variadic argument if it is a macro-name
- From: "potswa at mac dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 10 Aug 2014 09:03:58 +0000
- Subject: [Bug preprocessor/61613] ,##__VA_ARGS__ fails to expand the first variadic argument if it is a macro-name
- Auto-submitted: auto-generated
- References: <bug-61613-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61613
David Krauss <potswa at mac dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |potswa at mac dot com
--- Comment #3 from David Krauss <potswa at mac dot com> ---
The surprising result is because you passed print to itself, and the ##
operator disables pre-expansion of argument tokens. If you want to expand
print(print(â)), you can use the double-expansion idiom used for other special
macros.
#define do_print(x,...) (print(1,"macro"),print(1, ##__VA_ARGS__))
#define print(...) do_print( __VA_ARGS__ )
GCC 2.95 is not a role model. Regardless of what future compilers do, you
should suggest the above fix to the Boost.ScopeExit maintainer.
Note that I plan to propose the current behavior for standardization; see
http://open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3882.pdf . (It is dated in
the past, but it has not been processed yet due to a technicality.) Your use
case does sound quite reasonable, but unless the implementations move soon, the
door might shut as it ceases to have the flexibility of a GCC extension.
On the other hand, if GCC does change here, I'll be compelled to propose
standardizing the update instead.