Failure to bind rvalue to a constant reference when rvalue is returned from virtual function - by DSN_SLO

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.

Sign in
to vote
ID 774268 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 12/13/2012 10:26:29 AM
Access Restriction Public


We've hit a compiler bug that will block our transition to Visual Studio 2012. When an object is returned by value from a virtual method and assigned to a constant reference, the object is immediately destructed instead of being bound to the constant reference. 

We've only been able to reproduce the problem when clr is enabled. If the virtual method is called statically, the problem does not occur. The problem does not occur when targeting VS2010 or VS2008 tool sets. 
Sign in to post a comment.
Posted by Deon [MSFT] on 4/29/2014 at 12:31 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from:
Posted by ATASLO on 6/26/2013 at 7:19 PM
This fix does not appear to have been included in VS 2012 Update 3, but is included in the Visual Studio 2013 Preview released on 2013.06.21 at
Posted by ATASLO on 4/5/2013 at 5:20 PM
This fix does not appear to have been included in VS 2012 Update 2.
Posted by Marian [MSFT] on 1/28/2013 at 11:54 AM
This issue has been fixed and will be available in our next public release of Visual Studio. Stay tuned for future announcements of public previews of our next version.

For the VS 2012 release, please use one of the workarounds to fix the lifetime of the returned variable (e.g. A a = tc->GetA();)

Marian Luparu
Visual C++
Posted by ATASLO on 1/8/2013 at 11:00 AM
How can we get access to the fix? VS2012 is unusable on our C++/CLR code base without this fixed.
Posted by rationull on 12/22/2012 at 12:34 AM
Can you give any idea when and in what form a fix for this problem will become available?
Posted by Macy [MSFT] on 12/13/2012 at 9:46 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 Macy [MSFT] on 12/13/2012 at 10:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(