Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid example in [diff.cpp11.lex] #306

Closed
jwakely opened this issue Jun 2, 2014 · 1 comment
Closed

Invalid example in [diff.cpp11.lex] #306

jwakely opened this issue Jun 2, 2014 · 1 comment

Comments

@jwakely
Copy link
Member

jwakely commented Jun 2, 2014

[diff.cpp11.lex] has this example:

#define M(x, ...) __VA_ARGS__
int x[2] = { M(1’2,3’4) };
// int x[2] = {};      — C ++ 2011
// int x[2] = { 3’4 }; — this International Standard

However, that isn't valid C++11, [cpp.replace]/4 says that for a variadic macro:

there shall be more arguments in the invocation than there are parameters in the macro definition (excluding the ...).

@FilipRoseen-refp
Copy link

I propose this minor rewrite of the example, it still maintains the same intent but is actually valid C++11 and C++14:

#define M(x, ...) __VA_ARGS__
int a[] = { M(1'2, 3'4, 5) };

// int a[] = { 5 };       — C++ 2011
// int a[] = { 3'4, 5 };  — this International Standard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants