-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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 objects must be nothrow copy constructible (ERR60-CPP) #531
Comments
Std::string would only throw if you run out of memory, right? The exceptions you're discussing would have strings that have ~100 bytes in them. If you run out of memory over 100 bytes, I dont think anyone actually expects to recover from that. I agree that this is a good goal, but personally, I treat things like std::string as effectively no-throw because there's no chance a program can recover from extreme low-memory like that. |
I agree that this is not a major issue. I just wanted to document it and maybe add more problems later. The document also proposes a fix I have not tried yet. |
To have nothrow-copy-constructible exceptions, we inherit from std::runtime_error which can cope with arbitrary-length error messages. Intermediate strings are built with static functions and then passed to the actual constructor.
The issue can be fixed by storing the message inside a The fix 53b501a can be merged when the CI builds complete. |
The SEI CERT C++ Coding Standard states in ERR60-CPP:
The user-defined exceptions all base on
detail::exception
which has astd::string
member. The exceptions have to be refactored to satisfystd::is_nothrow_copy_constructible
.The text was updated successfully, but these errors were encountered: