You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some circumstance -I have a hard time reducing the repro, compiling with MSVC 2019 and /std=c++17 /permissive-, I get error C2131.
Here is the repro I have so far:
#include<string>/// Returns the length of a C style array (that has not decayed into a pointer)template <typename T, std::size_t sz>
inlineconstexpr std::size_tlengthof(T (&)[sz])
{
return sz;
}
#include"https://raw.githubusercontent.com/aantron/better-enums/0.11.3/enum.h"namespacefoo {
BETTER_ENUM(bar, int,
one,
two
);
} //namespace foo
and the result:
<source>(15): error C2131: expression did not evaluate to a constant
<source>(15): note: failure was caused by call of undefined function or one not declared 'constexpr'
<source>(15): note: see usage of 'foo::bar::bar'
This really looks like a compiler bug (the enum constructor not being seen as constexpr), but given the difficulty to reduce the repro, I cannot tell what it is and if there is workaround...
The text was updated successfully, but these errors were encountered:
I have finally managed to reduce the issue -without better enum.
#include<cstddef>/// Returns the length of a C style array (that has not decayed into a pointer)template <typename T, std::size_t sz>
inlineconstexpr std::size_tlengthof(T (&)[sz])
{
return sz;
}
structfoo
{
structbar {};
constexprexplicitfoo(bar) {}
};
inlineconstexpr foo foo{foo::bar{}};
In some circumstance -I have a hard time reducing the repro, compiling with MSVC 2019 and
/std=c++17 /permissive-
, I get error C2131.Here is the repro I have so far:
and the result:
Easily reproducible on godbolt.
This really looks like a compiler bug (the enum constructor not being seen as
constexpr
), but given the difficulty to reduce the repro, I cannot tell what it is and if there is workaround...The text was updated successfully, but these errors were encountered: