C++ parser places point of declaration incorrectly for some initialization syntaxes - by Seth__

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 695909 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 10/20/2011 11:32:12 AM
Access Restriction Public


The C++ standard states that "The point of declaration for a name is immediately after its complete declarator (Clause 8) and before its initializer (if any) [...] ."[1] Consider the following declarations:

int i = i;
int x(x);

Examining the grammar reveals that in both declarations the complete declarator ends before the '=' and '(' respectively[2], and that the second use of the name is in the initializer and not the declarator. Therefore the C++ scoping rules say that in both cases the name refers to the object being declared (and so the object is initialized with its own indeterminant value)[3].

Visual Studio's C++ compiler does behave this way in the former case, but not in the latter. In the latter case the compiler behaves as though the point of declaration is after the closing ')', and it is possible to produce programs that behave incorrectly based on this.

[1] C++ 2011 FDIS n3290: § 3.3.2 Point of declaration
[2] C++ 2011 FDIS n3290: § 8.5 Initializers
[3] C++ 2011 FDIS n3290: § 3.3.3 Block scope
Sign in to post a comment.
Posted by Microsoft on 10/27/2011 at 2:52 PM
Thank you for reporting this issue to Microsoft. It looks like it's indeed a (minor) bug that's been in the compiler many years. Unfortunately, the severity of the bug does not let us fix it for the next release but we'll consider it for future releases.

Tanveer Gani
Visual C++ Team.
Posted by MS-Moderator07 [Feedback Moderator] on 10/20/2011 at 7:06 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Posted by MS-Moderator01 on 10/20/2011 at 11:42 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)