GCC gives me the error "argument template 2 is invalid" when I try to instantiate such a template (see line using Check ). I was very curious that I can get a pointer to an element using decltype outside the list of template parameters, but not inside it (see p2 variable definition). Indeed, Klang compiled this code. Is this a bug in GCC, or is this code actually invalid and is Clang just too inclusive?
template <class T, T t> struct checker_template {}; struct S { int n; }; int main() { S s; constexpr auto p1 = &S::n; constexpr auto p2 = &decltype(s)::n; using Check = checker_template<int S::*, &decltype(s)::n>; return 0; }
source share