Closed sthalik closed 1 year ago
Base: 97.39% // Head: 97.94% // Increases project coverage by +0.55%
:tada:
Coverage data is based on head (
8f81721
) compared to base (4ff543d
). Patch has no changes to coverable lines.:exclamation: Current head 8f81721 differs from pull request most recent head ece28cb. Consider uploading reports for the commit ece28cb to get more accurate results
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Actually, I'm still not sure what is the main reason the change to CORRADE_CONSTEXPR14
is needed.
Apart from MSVC, are there any relevant compilers that report C++14 as supported via the __cplusplus
macro but don't actually support C++14 constexpr (is that scenario even allowed by the standard?)? I suspect not, or at least no versions that'd still be widely used in distros or OSes. And since you have another dedicated check for MSVC >= 2017 in the #if
(does that mean __cpp_constexpr
didn't work?), I think the macro could still check for CORRADE_CXX_STANDARD >= 201402
like before. Which significantly simplifies everything, since the test doesn't need to handle the case of "C++14 supported but C++14 constexpr not" at all.
Then, for MSVC, isn't it just about excluding MSVC 2015? It would boil down to
#if CORRADE_CXX_STANDARD >= 201402 && !defined(CORRADE_MSVC2015_COMPATIBILITY)
#define CORRADE_CONSTEXPR14 constexpr
...
#endif
and using CORRADE_MSVC2015_COMPATIBILITY
to special-case the test, just for this one compiler, assuming sanity everywhere else:
void MacrosCpp14Test::constexpr14() {
#ifdef CORRADE_MSVC2015_COMPATIBILITY
CORRADE_SKIP("CORRADE_CONSTEXPR14 not available on MSVC2015.");
#else
constexpr int sum = sumInAStupidWay(17);
CORRADE_COMPARE(sum, 153);
#endif
}
[Sorry for the accidental close, pressed too many buttons at once.]
Apart from MSVC, are there any relevant compilers that report C++14 as supported via the __cplusplus macro but don't actually support C++14 constexpr
Compilers tend to expose -std=c++14
before it's fully implemented or even before the standard is finalized (see how different versions of concepts or ranges were implemented). Quite a few of the CI bots are running GCC 4.8 which has this problem.
https://gcc.gnu.org/projects/cxx-status.html -- 4.3 -> 5.0 https://clang.llvm.org/cxx_status.html - 2.9 -> 3.4 https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance - 2013 12.0 -> 2017 15.0*
Which significantly simplifies everything, since the test doesn't need to handle the case of "C++14 supported but C++14 constexpr not" at all.
The whole point is to handle that for cases such as Magnum vector code. Or am I meant to litter it with _MSC_VER
and __GNUG__
?
Compilers tend to expose
-std=c++14
before it's fully implemented
Yes, -std=c++xy
is, but I'm talking about the __cplusplus
macro, which is defined to 2014xy
only on GCC 5+. Which solves the problem for GCC 4.8, it was already working there correctly even before this PR. Old Clangs are irrelevant nowadays, so there's no point in distinguishing anything there; and for MSVC we have to special-case anyway.
I'm not trying to solve the general case of "is feature X supported completely and without bugs on compiler Y", here it's just about having the simplest possible condition for "is C++14 constexpr supported on compilers we care about", and since C++14 is rather old and the relevant compilers are dying out, it can be coarser than, say, checking for consteval
support. Which is what #if CORRADE_CXX_STANDARD >= 201402 && !defined(CORRADE_MSVC2015_COMPATIBILITY)
does.
The whole point is to handle that for cases such as Magnum vector code. Or am I meant to litter it with
_MSC_VER
and__GNUG__
?
What? Why? The whole point here is to define the macro in a way that does the right thing without a need for extra checks every time it's used, and have a test that verifies it indeed does the right thing.
I guess easiest is if I just do the thing instead of talking about it. The CORRADE_CONSTEXPR14
part is merged as fbb9305265fd2fe89e45893108f9e0ee686c341d, with the corresponding test in bee514f31d1d58e0905683dab3d23a903ff930a8, for both the C++11 and the C++14 case. All CIs pass.
Note, it's specifically not meant to be used as if constexpr(std::is_constant_evaluated()) ...
, because in that case it always returns true.
This is going to be used in Magnum vectors.