This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug preprocessor/61613] ,##__VA_ARGS__ fails to expand the first variadic argument if it is a macro-name


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]