Home Dashboard Directory Help
Search

C++11 non-conforming __VA_ARGS__ macro expansion (C4003) by Igor 'arabesc' Pavlov


Status: 

Closed
 as Deferred Help for as Deferred


1
0
Sign in
to vote
Type: Bug
ID: 772051
Opened: 11/23/2012 6:30:33 AM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description

Microsoft Visual Studio Ultimate 2012
Version 11.0.51020.03 Update 1 CTP

Visual C++ 2012 04940-004-0038003-02800
Microsoft Visual C++ 2012

Visual C++ Compiler November 2012 CTP [Codename Milan] installed.

There is nonstandard __VA_ARGS__ expansion.

C++11 draft:
16.3.1 Argument substitution
1. After the arguments for the invocation of a function-like macro have been identified, argument substitution takes place. A parameter in the replacement list, unless preceded by a # or ## preprocessing token or followed by a ## preprocessing token (see below), is replaced by the corresponding argument after all macros contained therein have been expanded. Before being substituted, each argument’s preprocessing tokens are completely macro replaced as if they formed the rest of the preprocessing file; no other preprocessing tokens are available.
2. An identifier __VA_ARGS__ that occurs in the replacement list shall be treated as if it were a parameter, and the variable arguments shall form the preprocessing tokens used to replace it.
Details
Sign in to post a comment.
Posted by Microsoft on 11/25/2012 at 11:13 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 11/23/2012 at 6:52 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Igor 'arabesc' Pavlov on 11/23/2012 at 6:32 AM
#include <iostream>

#define PP_SUBST(arg) arg
#define PP_TEST(...) PP_SUBST(PP_TEST2(__VA_ARGS__))
#define PP_TEST2(a, b) #a

int main()
{
    std::cout << PP_TEST(0, 1) << std::endl;
}