Changed implementation of gsl::narrow to throw gsl::narrowing_error#873
Conversation
Implementation now behaves as described in the C++ Core Guidlines
|
I took a look at the build issues you're having. Deleting the file That file exists because of the old terminate vs throw behavior and is no longer needed. |
|
@JordanMaples #873 (comment) I wasn't sure if you wanted to keep the no-throw option for narrow and there doesn't seem to be a define to control if GSL should be no-throw. If you are happy to remove that scenario I can remove the test. |
|
Thanks again for finding this issue and getting the fix ready. |
|
@JordanMaples I was thinking about upgrading to GSL 3.0. Seeing this fix here (and using gsl::narrow in my code) I now know that I cannot use GSL 3.0. Do you plan to release a new version of GSL like 3.1 with this fix here included? |
|
@beinhaerter My original plan was to release 3.1.0 when the span paper P1976R2 was implemented, but I think this warrants a minor release. I'll be pushing 3.0.1 today. |
|
@beinhaerter I've released 3.0.1. |
Related to issue #872
Reinstated throwing behaviour of
gsl::narrowdescribed in C++ Core Guidlines ES.46https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es46-avoid-lossy-narrowing-truncating-arithmetic-conversions