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

make extern "C" functions explicitly noexcept #4106

Merged
merged 6 commits into from
Oct 25, 2023

Conversation

CaseyCarter
Copy link
Member

@CaseyCarter CaseyCarter commented Oct 19, 2023

Functions declared extern "C" are implicitly noexcept(true) when compiling with /EHc, and implicitly noexcept(false) when compiling without. To ensure consistency regardless of the compiler's command line options, all extern "C" functions should have explicit noexcept-specifiers.

This change excludes (with explanatory comment) the redeclarations of locale.h functions in xlocinfo to avoid clashing with the primary declarations in the UCRT.

Drive-by:

  • In mutex.cpp, indicate that _Thrd_abort is exported for ABI only; there are no callers outside this file.
  • In winapisupp.cpp, the dynamic initializer initialize_pointers never throws exceptions and should therefore be noexcept.
  • In vector_algorithms.cpp, the APIs are noexcept so the helpers must be as well. Add annotations to make that contractual obligation explicit.

Excludes (with explanatory comment) the redeclarations of `locale.h` functions in `xlocinfo` to avoid clashing with the primary declarations.

Drive-by in `mutex.cpp`: Indicate that `_Thrd_abort` is exported for ABI only; there are no callers outside this file.
@CaseyCarter CaseyCarter added the enhancement Something can be improved label Oct 19, 2023
@CaseyCarter CaseyCarter requested a review from a team as a code owner October 19, 2023 05:34
@StephanTLavavej StephanTLavavej self-assigned this Oct 19, 2023
stl/inc/execution Outdated Show resolved Hide resolved
stl/inc/xlocinfo Outdated Show resolved Hide resolved
stl/src/excptptr.cpp Outdated Show resolved Hide resolved
stl/src/mutex.cpp Outdated Show resolved Hide resolved
stl/src/pplerror.cpp Outdated Show resolved Hide resolved
stl/src/ppltasks.cpp Outdated Show resolved Hide resolved
stl/src/stdhndlr.cpp Outdated Show resolved Hide resolved
stl/src/vector_algorithms.cpp Show resolved Hide resolved
stl/src/winapisupp.cpp Show resolved Hide resolved
@StephanTLavavej StephanTLavavej removed their assignment Oct 19, 2023
stl/src/vector_algorithms.cpp Outdated Show resolved Hide resolved
stl/src/ppltasks.cpp Outdated Show resolved Hide resolved
stl/src/dllmain.cpp Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej removed their assignment Oct 24, 2023
@StephanTLavavej StephanTLavavej self-assigned this Oct 24, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 0b9ec10 into microsoft:main Oct 25, 2023
35 checks passed
@StephanTLavavej
Copy link
Member

Thanks for this big consistency improvement! 🎉 ✅ 😻

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

Successfully merging this pull request may close these issues.

2 participants