Repository navigation
Silence Clang -Wc++20-extensions - #737
Merged
Casey Carter (CaseyCarter) merged 1 commit intoApr 25, 2020
Merged
Conversation
Stephan T. Lavavej (StephanTLavavej)
requested a review
from a team
as a code owner
April 22, 2020 23:23
Charlie Barto (barcharcraz)
approved these changes
Apr 22, 2020
Member
|
:sigh: I really wish clang had a 'there are no system headers' option :( |
Billy O'Neal (BillyONeal)
approved these changes
Apr 22, 2020
Casey Carter (CaseyCarter)
approved these changes
Apr 23, 2020
Contributor
|
Thanks for the cleanup! |
Contributor
|
If we allow C++17 |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
pair,tuple, andoptional, we use C++20 conditionalexplicit(akaexplicit(bool)) to simplify constructors and improve compiler throughput, when compiler support is available:STL/stl/inc/optional
Lines 182 to 193 in 0cbd1b2
Like C++17
if constexpr, MSVC supports C++20explicit(bool)in older Standard modes, with a suppressible warning. (This is because the feature requires novel syntax, so it can't be accidentally used, and it's extremely useful to library developers.) We suppress both warnings in STL headers:STL/stl/inc/yvals_core.h
Lines 368 to 380 in 0cbd1b2
Clang 9 supported
explicit(bool)in C++20 mode, while Clang 10 added "downlevel" support similar to MSVC. When #708 changed the STL to require Clang 10, it also began using Clang 10's downlevel support forexplicit(bool).Curtis J Bezault (@cbezault) discovered that we forgot to suppress the warning that Clang emits for
explicit(bool)in older Standard modes. We missed this because Clang (unlike MSVC) ordinarily suppresses warnings from "system headers". (-Wsystem-headersactivates warnings in system headers, although this is rarely used because users are rarely interested in such warnings, and UCRT/WinSDK headers are still being cleaned up.)This is a practical issue because anything on the
INCLUDEpath is considered to be a system header for warning purposes, while/Idirectories aren't (despite#includesearching bothINCLUDEand/I). During STL development, it is very convenient to be able to compile with/I S:\GitHub\STL\stl\incand immediately consume updated STL headers without rebuilding (this is not possible when separately compiled changes are involved, of course), which will emit Clang warnings.After this lengthy backstory, the fix is delightfully simple.