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
[unique.ptr.single] Throwing after 079f7d3b02d can be well-defined #4872
Comments
No, throwing an exception in these situation is still a precondition violation -> undefined behavior. The unconditional "noexcept" just means no exception will escape, but regardless you still need to play by the rules (i.e. satisfy the preconditions). |
https://timsong-cpp.github.io/cppwp/n3337/unique.ptr.single.ctor |
Is that the right commit ID? It didn't add any I agree that making it UB is bad. We should just rely on the compiler to terminate. We should try to reduce the places where programs have unnecessary undefined behaviour. But I think this needs an lwg issue. |
No.
Yes. This seems like a low-hanging fruit compared to other sources of library UB. I'll take a look again and submit a LWG issue. |
079f7d3 added
noexcept
to certain constructors that had the precondition that some initialization didn't throw. Before, the effects was that throwing results in undefined behavior according to [structure.specifications]. 079f7d3 didn't remove the preconditions, but an exception throw within anoexcept
function is well-defined. Could this have been an oversight?The text was updated successfully, but these errors were encountered: