Details
-
Type:
Bug
-
Status: Closed
-
Priority:
P3: Somewhat important
-
Resolution: Done
-
Affects Version/s: 5.4.2
-
Fix Version/s: 5.9.1
-
Component/s: Core: Containers and Algorithms
-
Labels:None
-
Environment:Windows 7, MSVC 2012
-
Commits:d1210281e41008ce2e3510aa5cfb3ebea1c57734
Description
QSharedPointer::create() improperly calls the destructor when the constructor throws an exception.
#include <QSharedPointer> class MyClass { public: MyClass() { qDebug("MyClass"); throw std::exception(); } ~MyClass() { qDebug("~MyClass()"); } }; int main(int argc, char *argv[]) { try { QSharedPointer<MyClass> withCreate = QSharedPointer<MyClass>::create(); } catch (const std::exception&) { } try { QSharedPointer<MyClass> withoutCreate( new MyClass() ); } catch (const std::exception&) { } }
The output is:
MyClass() ~MyClass() MyClass()
The output should be:
MyClass() MyClass()
Attachments
Issue Links
- replaces
-
QTBUG-51017 QSharedPointer<T>::create calls T::~T even when T::T throws
-
- Closed
-
For Gerrit Dashboard: QTBUG-49824 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
191756,7 | Fix undefined behavior in QSharedPointer::create() | 5.8 | qt/qtbase | Status: MERGED | +2 | 0 |