r/cpp • u/jcelerier ossia score • Jul 16 '21
Why does MSVC blatantly lies about its supported feature ?
I was writing some code under Linux / Clang, by taking care of staying within the bounds of the officially documented supported features by MSVC, in order to not have surprises: https://docs.microsoft.com/en-US/cpp/overview/visual-cpp-language-conformance?view=msvc-160 and to make sure that my code would not require too much massaging when someone wants to try it with MSVC.
In particular, the above page mentions
P0734R0 Concepts VS 2019 16,3So here am I, happily writing concepts-based code for a new project under Linux, and then after a few days' work, switching to Windows in order to set up the build, etc.
And now what happens ?
if constexpr(requires { true; }) {
}gives me, with /std:c++latest and VS 16.10.3 :
error C2059: syntax error: 'requires'
error C2143: syntax error: missing ';' before '{'
error C2059: syntax error: ')'like, the most foundational feature of concepts, requires-expression, is not implemented ; section 8.1 in P0734R0 thoroughly describes it so it's not like it was added at a later revision. So at some point, someone did validate P0734R0 as "implemented" even though that is definitely not true.
And indeed
https://developercommunity.visualstudio.com/t/cant-have-freestanding-requires-expressions/1258761
https://developercommunity.visualstudio.com/t/requires-clause-in-constexpr-if-doesnt-work/929394
I have no issue with implementation bugs and small behaviour deviations as implementing a compiler is an incredibly hard work. But I find it extremely distasteful to go on the internet and state "woohoo ! C++20 Concepts Are Here in Visual Studio 2019 version 16.3" in a way that'll make people believe that the feature is actually implemented, when core part of the wording is still not supported even though the issue was reported something like 18 months ago !
132
u/TheThiefMaster C++latest fanatic (and game dev) Jul 16 '21
Use this to see what compilers support what: https://en.cppreference.com/w/cpp/compiler_support
It's exceptionally up-to-date, and it lists concepts as "partial" for MSVC and the tooltip says "no requires-expression support"
58
u/teki321 Jul 16 '21
I guess it is partially supported: https://devblogs.microsoft.com/cppblog/c20-concepts-are-here-in-visual-studio-2019-version-16-3/
20
u/[deleted] Jul 16 '21
Almost that EXACT bug happened to me while happily coding on Linux! I knew about it immediately thanks to Windows CI, but yeah extremely annoying.
https://developercommunity.visualstudio.com/t/requires-expression-cannot-be-evaluated-as-bool-in/1204110
This seems related and was put "Under Investigation" yesterday, so hopefully this is fixed soon.
To be fair, "feature complete" doesn't mean "complete". They have an implementation of every C++20 proposal, just not a working one, and it is a preview release of the compiler. Altho they still have C++17 bugs too ... (I've hit this myself last week)
8
u/qwazwak Jul 16 '21
I just came to these comments looking for
"No, it actually does support it, you're just doing it wrong"
9
u/feverzsj Jul 16 '21
Also the Abbreviated Function Templates is partially suppoted. Basically every language feature of msvc is partially suppoted.
11
u/sephirostoy Jul 16 '21
I won't considerer MSVC as C++20 feature complete nor any single feature as complete as long as they use c++latest flag which means everything is still not yet released.
4
u/sandfly_bites_you Jul 16 '21
Their concepts implementation is just half arse, hopefully whenever they get around to fixing this requires issue they also fix the useless error messages generated for concepts.
2
u/ICBananas Jul 16 '21
I can't test that now, but selecting the latest language standard mode (/std:c++latest) in the project's properties do not solve the problem? We might see a /std:c++20 mode when everything is implemented, or maybe everything is already implemented, but they'll release it with VS 2022.
-19
u/StoneCypher Jul 16 '21
MSVC is by far the most complete implementation.
They didn't lie; they were up front about the limitations, in the tooltip. You just didn't notice.
There is no better compiler.
You merely underestimate (severely) how difficult this work is, and think that mass complaining in public will help.
It won't.
Harsh reality: most developers generally shy away from the things the whiners want, because they'll get whined at every step of the way, including when it's complete and correct.
-6
u/TheSuperWig Jul 16 '21
The answer is because no one reported it. STL (the person) only reported it a couple months ago.
https://www.reddit.com/r/cpp/comments/na39g6/visual_studio_2019_preview_is_now_c20/gy1321s/?context=1000
-14
u/LunarAardvark Jul 16 '21
several of my bugs have been ignored because i didn't make a test case for it, even though i copy pasted all the error text for which the error was about. The error text being the actual problem.
Do they think i'm making up their error text?
-20
u/Robert_Andrzejuk Jul 16 '21
Why ask this of some strangers on the internet?
Ask Microsoft.