Consider that minimized code snippet:
#include <vector>
class Bar
{
public:
constexpr Bar() {}
};
consteval Bar foo()
{
return Bar();
}
int main()
{
std::vector<Bar> bars{ foo(), foo() };
}
This doesn't compile on latest MSVC compiler (Visual Studio 2022 version 17.3.3), but does on Clang or GCC.
Compiler Explorer
Is the code somewhere ill formed, or it is a bug in MSVC?
From the comments, it looks like this is indeed a bug in MSVC.
Therefore I filled in a bug report on Visual Studio Community.
https://developercommunity.visualstudio.com/t/Cannot-use-consteval-functions-returning/10145209
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With