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

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 663904 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 4/21/2011 9:06:09 AM
Access Restriction Public

Description

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.
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)