Skip to content
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

gsl not_null throw exception #2132

Open
jonnygrant opened this issue Sep 5, 2023 · 1 comment
Open

gsl not_null throw exception #2132

jonnygrant opened this issue Sep 5, 2023 · 1 comment

Comments

@jonnygrant
Copy link

jonnygrant commented Sep 5, 2023

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-nullptr

Was throwing an exception considered? ie. std::logic_error or std::invalid_argument

Perhaps it is left implementation defined, as I can't spot a specific behavior described.

Presently GSL calls std::terminate(), quite a strong response. gsl-lite is the same.

An exception gives the application a chance to handle it (even if that was just gracefully logging). The user wouldn't be impacted by a std::terminate core dump SEGV; which is a bad outcome in a safety critical environment. Even worse in a library, we can't link to anything that might call std::terminate() like this in a safety critical environment; would be an uncontrolled program termination event.

Here is a one file example based on https://github.com/gsl-lite/gsl-lite

https://godbolt.org/z/Wdea6G9EW

This isn't production code, just an example.

@shaneasd
Copy link
Contributor

shaneasd commented Sep 8, 2023

Related: #1561

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants