Home Dashboard Directory Help
Search

Compilation error in case of repeating forward declaration within class by Adam Badura


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 625710
Opened: 11/30/2010 6:54:41 AM
Access Restriction: Public
1
Workaround(s)
view
0
User(s) can reproduce this bug

Description

There is bug in the compiler revealed if a forward declaration of a class is reaped within a different class and that declared class is used in some templates (but in a legal way). The issue was discussed at http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/bd2c2ad4-0377-4aea-b312-2b311ede5191.
Details
Sign in to post a comment.
Posted by Microsoft on 2/7/2011 at 10:42 AM
Hi Adam,
    Thanks for reporting the issue.

    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

    Note that repeating forward declaration within class is not allowed according to C++ standard, 9.2 Class members:

    A member shall not be declared twice in the member-specification, except that a nested class or member class template can be declared and then later defined.

    VC doesn't fully honor the above requirement, and will accept your code. But it is better not to write code like this.

Xiang Fan
Visual C++ Team
Posted by Microsoft on 11/30/2010 at 7:21 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 Adam Badura on 11/30/2010 at 6:56 AM
This particular example can be worked around by moving the test::create function after both Part 1 and Part 2. I don't know if this is also a general workaround for this class of problems.