Search

Compiler fails to compile inner struct/class/union in a namespace after some forward declarations by Adam Rosenfield

Closed
as Fixed Help for as Fixed

1
0
Sign in
to vote
Type: Bug
ID: 663904
Opened: 4/21/2011 9:06:09 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
The following C++ code fails to compile in Visual Studio 2010:

namespace N
{

typedef void (*F)(int, struct S*);

struct S
{
struct I { };
};

}

int main(void)
{
return 0;
}


The error message is on line 8:
error C2888: 'S::I' : symbol cannot be defined within namespace 'N'

If the declaration for F is removed (which contains a forward declaration of S), or if it is changed slightly (such as by removing the first 'int' parameter), the error message goes away and the code compiles successfully.
Details (expand)

Visual Studio/Silverlight/Tooling version

Visual Studio 2010

What category (if any) best represents this feedback?

Compatibility

Steps to reproduce

Compile the code sample above.

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

The code fails to compile with error C2888.

Expected results

The code compiles with no errors.
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 5/2/2011 at 10:24 AM
Hello Adam,

Thank you for taking the time report this compiler bug. We will consider fixing this bug in a future release. In the meantime, please accept this workaround if possible. We apologize for the inconvience Adam.

namespace N
{
    struct S;
    typedef void (*F)(int, S*);

    struct S
    {
        struct I { };
    };

}

int main(void)
{
    return 0;
}

Thanks,
Ulzii Luvsanbat
Windows C++ Team
Posted by Microsoft on 4/21/2011 at 7:01 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 review. We will contact you if we require any additional information.
Posted by Microsoft on 4/21/2011 at 9:14 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.