microsoft / GSL

Guidelines Support Library
Other
6.13k stars 737 forks source link

Fix Clang-15 warnings #1058

Closed RSilicon closed 1 year ago

RSilicon commented 1 year ago

These warnings were found by running clang-tidy 15.

dmitrykobets-msft commented 1 year ago

Hi @AtariDreams, can you please describe the warning instances you are fixing, and the warning flags you used to enable the warnings? I'm having a hard time reproducing any warnings for this file when compiling with clang 15 with -Wall -Weverything -pedantic -Wextra

RSilicon commented 1 year ago

@dmitrykobets-msft I apologize. This was clang-tidy with these warnings. I also removed the ones that don't matter.

dmitrykobets-msft commented 1 year ago

Thanks @AtariDreams, The compiler will attempt to mark default-ed move constructors as noexcept in cases where appropriate. Your modification to always force it to be noexcept will change the current exception behavior. For instance, if a custom smartpointer type decides to throw on copy, then wrapping it in not_null and using the noexcept move constructor will call std::terminate, whereas without the noexcept, the exception will be propagated.

The other changes look good to me.

RSilicon commented 1 year ago

I do not see where it can throw on copy or why, but I will take your word on it.

RSilicon commented 1 year ago

Also default copy constructors do not throw on copy

RSilicon commented 1 year ago

@dmitrykobets-msft

dmitrykobets-msft commented 1 year ago

Edited my earlier comment to hopefully make my noexcept concern clearer.