-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<exception>: Invalid destruction of non-copyable throwables during exception_ptr rethrow #2466
Comments
This comment has been minimized.
This comment has been minimized.
I found some links: https://en.cppreference.com/w/cpp/language/throw
https://wg21.cmeerw.net/cwg/issue1863
|
The bug here is - per [except.throw]/5 - the compiler failing to diagnose that |
Are you positive that this is a compiler bug and the deleted/non-existent copy constructor is called? How did you verify that? I have some doubts because I did more tests with other compiler / STL combinations: |
Yes, it's clear: the standard says "the constructor selected for a copy-initialization considering the thrown object as an lvalue shall be non-deleted and accessible." This program violates that diagnosable constraint, so the compilers should diagnose it.
"The problem" is the lack of diagnostic, which does reproduce with Clang + libc++. And GCC + libstdc++, for that matter. |
@CaseyCarter |
I think a conforming C++ compiler must give a compilation error for the initial code.
|
Interesting! This citation is from "cppreference.com", right? Do you happen to know the original citation in the c++ standard? I don't seem to find it. |
I think that line from cppreference is paraphrased the line from the standard:
Cubbi added the line after cwg-1863 was accepted. https://en.cppreference.com/mwiki/index.php?title=cpp%2Flanguage%2Fthrow&diff=81680&oldid=74819 |
I created issues: |
Someone from Microsoft also ran into the issue: DevCom-1645768 |
Off-topic: it seems that we (editors of cppreference) should complete the "Reference" sections of cpp pages (which cite the corresponding sections in all related revisions of C++ standard). |
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).
The text was updated successfully, but these errors were encountered: