Describe the bug
If you rethrow an object with deleted copy-constructor via an exception_ptr, it will corrupt the memory and crash.
Command-line test case
C:\Temp>type repro.cpp
#include <exception>
#include <string>
using namespace std;
class C {
public:
C() = default;
C(const C&) = delete;
C& operator=(const C&) = delete;
C(C&&) = default;
C& operator=(C&&) = default;
private:
string m;
};
int main() {
exception_ptr eptr;
try {
throw C();
} catch (const C&) {
eptr = std::current_exception();
}
try {
rethrow_exception(eptr);
} catch (const C&) {
}
}
C:\Temp>cl /EHsc /W4 /WX .\repro.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.23.28019.1 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
repro.cpp
Microsoft (R) Incremental Linker Version 14.23.28019.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:repro.exe
repro.obj
C:\Temp>.\repro.exe
test failure
Expected behavior
Does not crash.
STL version
MSVC build tools 14.28, 14.29, 14.30, 14.31 (reproes in all of them).
Describe the bug
If you rethrow an object with deleted copy-constructor via an
exception_ptr, it will corrupt the memory and crash.Command-line test case
Expected behavior
Does not crash.
STL version
MSVC build tools 14.28, 14.29, 14.30, 14.31 (reproes in all of them).