I'm seeing a compile error in MSVC with this:
constexpr auto f =
[](auto&& x, auto&&... someOtherStuff) noexcept(noexcept(x)) {};
which gives me
<source>(3): error C2760: syntax error: 'someOtherStuff' was unexpected here; expected ')'
And as I changed things around, this shouldn't compile but I get an internal compiler error:
constexpr auto g =
[](auto&&... someOtherStuff) noexcept(noexcept(int)) {}; //< ICE
https://godbolt.org/z/faKKfjdPx
Is f
, above, correct C++? It (and the ICE) goes away with /std:c++20
or with other compilers.
Yes, f
is correct, but g
is not:
Syntax
noexcept( expression )
int
is not an expression, but the compiler should of course not ICE.
Without compiling with /permissive-
in pre C++20, MSVC follows its own rules (often in conflict with standard C++ rules) and doesn't compile f
. If you do add /permissive-
or upgrade to C++20 (which sets /permissive-
by default), the error goes away.