Search

C++11 enum class can be converted to nullptr by Mogens Hansen

Closed
as Deferred Help for as Deferred

1
0
Sign in
to vote
Type: Bug
ID: 779611
Opened: 2/20/2013 6:53:52 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
The code

enum class test { ZERO, ONE };

int main()
{
    const test zero = test::ZERO;
    int*    x = zero;
}

can compile - it shouldn't
Details (expand)

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

Visual Studio 2012

Steps to reproduce

1. Create an empty C++ console application
2. Enter the code
enum class test { ZERO, ONE };

int main()
{
    const test zero = test::ZERO;
    int*    x = zero;
}

3. Notice that it compiles without error

It the code is changed to
enum class test { ZERO, ONE };

int main()
{
    int*    x = test::ZERO;
}

it doesn't compile, but generates an
"error C2440: 'initializing': cannot convert from 'test' to int*"
which is correct

Product Language

English

Operating System

Windows 8

Operating System Language

Afrikaans

Actual results

A running program

Expected results

A compilation error
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/22/2013 at 2:43 AM
Thank you for submitting feedback on Visual Studio 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 Microsoft on 2/21/2013 at 1:51 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.