Reputation: 321
MSVC fails to compile
#include <iostream>
template<int N, int = N>
struct A;
template<int, int V>
struct A{static constexpr int VALUE = V;};
int main() {
A<1> a;
std::cout << a.VALUE;
}
with (3): error C2065: 'N': unknown identifier
(10): error C2975: 'V': invalid template argument 'A', constant expression expected
(roughly translated).
clang compiles it silently.
So, the question: rotten code or demented MSVC?
MSVC version = VS 2019.
Upvotes: 7
Views: 93
Reputation: 21201
It was a bug in MSVC manifested up to compiler version 19.22, and fixed in 19.23. Demo: https://gcc.godbolt.org/z/occvKEfc3
Upvotes: 1