Search

Invalid ## arguments in _VAR_TYPE in xstddef by Steve Cornett

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 712897
Opened: 12/9/2011 4:45:49 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
0
User(s) can reproduce this bug
In the header xstddef there is a macro named _VAR_TYPE that contains an invalid usage of the ## operator:

#define _VAR_VAL(NUM) \
    _V ## NUM
#define _VAR_TYPE(NUM) \
    _VAR_VAL(NUM) ## _t

This usage pastes the ')' token with the result of expanding _t, which can never form a valid token, and is not the apparent intention. The problem can be corrected with the definition below. This change is the resolution to this bug:

#define _VAR_TYPE(NUM) \
    _V ## NUM ## _t

The symptom of the problem does not occur with Microsoft C++ alone, but occurs when the code is preprocessed by another product such as our product, BullseyeCoverage. You can also demonstrate the problem by expanding the macro with another compiler such as GCC 4.5.2, or Embarcadero C++ 6.42.

For additional info, see http://www.bullseye.com/help/trouble_microsoftPaste.html
Details (expand)

Visual Studio/Team Foundation Server/.NET Framework Tooling version

Visual Studio 11 Developer Preview

Steps to reproduce

Run the command "cl -E bug.cpp", where bug.cpp contains this:

#define _VAR_VAL(NUM) \
    _V ## NUM
#define _VAR_TYPE(NUM) \
    _VAR_VAL(NUM) ## _t
_VAR_TYPE(aToken)

The output is incorrect. Do not be fooled by the fact that it looks correct compared to what was intended. It's wrong:

_VaToken_t

GCC produces the correct result (and an error message). Run the command "g++ -E bug.cpp"

bug.cpp:5:1: error: pasting ")" and "_t" does not give a valid preprocessing token
_VaToken _t

Note the space. The correct output is two tokens.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

see above

Expected results

see above
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 1/18/2012 at 8:17 PM
Hi,

Thanks for reporting this bug. We've fixed it (in both _VAR_TYPE and _VAR_TYPEX), and the fix will be available in VC11.

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by MS-Moderator08 [Feedback Moderator] on 12/11/2011 at 10:15 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by MS-Moderator01 on 12/9/2011 at 5:43 PM
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.