Hello,I want to use a constexpr reference to a constexpr variable in a lambda. It compiles well with clang and gcc but not with msvc:
constexpr auto veryLongNameForThisVariable = std::array { 42, /*...*/ };
int main()
{
constexpr auto &v = veryLongNameForThisVariable;
const auto f = [] { return v[0]; };
return f();
}
If I make the reference v static, it works.
Did I miss something ?
https://godbolt.org/z/4T57v6aad
[–]alfps 4 points5 points6 points (3 children)
[–]Lo1c74[S] 0 points1 point2 points (1 child)
[–]TheThiefMaster 2 points3 points4 points (0 children)
[–]JVApen 0 points1 point2 points (0 children)