Search

Warnings/Code Analysis not picking up self-initialisation by Gregory Currie

Closed
as Deferred Help for as Deferred

1
0
Sign in
to vote
Type: Bug
ID: 777725
Opened: 1/28/2013 9:06:43 PM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
[Codename Milan] Failure to detect obvious UB invoking initialization and emit warning
Details (expand)

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

Visual Studio 2012

Steps to reproduce

struct Test {
int &i;
Test():i(i){}
};
int main() {
}

The code above is expected to produce a warning, either with or without using code analysis. I don't believe the code above is ever correct, and I suspect it is UB. Due to the nature of references, 'i' can never become valid during the lifetime of the application.

Product Language

English

Operating System

Any

Operating System Language

English

Actual results

Compilation success

Expected results

Warning, (or even error if this is allowed by the standard)
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 2/12/2013 at 4:36 PM
Hi Gregory,

Thanks for the suggestion. We will consider implementing the detection of such errors in a future release of Visual Studio.

Karl Niu
VC++ Team
Posted by Microsoft on 1/29/2013 at 1:23 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 1/28/2013 at 9:50 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.