Home Dashboard Directory Help
Search

Destructor of temporary object not executed by Valentin Z


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 785647
Opened: 4/26/2013 1:55:52 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description


If a temporary X is bound to a reference member in a constructor's ctor-intializer, the destructor of X is never executed.

Example:

struct A;

struct B {
    A const& a;
    B() : a(A()) {} // A::~A is not executed after constructor exits.
};
Details
Sign in to post a comment.
Posted by Microsoft on 4/26/2013 at 3:15 AM
Thanks for your feedback. We have marked this bug as a duplicate of Feedback item 761742. Please see the issue linked to this bug for updates.
http://connect.microsoft.com/VisualStudio/feedback/details/761742/failed-to-call-destructor-of-a-temporary-bound-to-a-reference-member-warning-c4413

Thank you,
Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 4/26/2013 at 2:50 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)
Posted by Valentin Z on 4/26/2013 at 2:24 AM
Just found out that the same problem has been reported before by Cassio Neri, see ID 761742.
Visual C++ Team says "The fix should show up in the next release of Visual C++".
Sorry for the inconvenience.
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
ConsoleApplication2.cpp 4/26/2013 373 bytes