https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44906
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |NEW Last reconfirmed|2011-09-23 00:00:00 |2021-8-3 --- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> --- For the testcase in comment #8: Ok, this is interesting as at first I thought this was fixed in GCC 11 but then I looked to see what the different standards do as GCC 11's default is C++17. With C++17 and C++20, we get: <source>:8:34: error: use of 'this' in a constant expression 8 | void add(void) { addVecVals<&vec1>(); } | ^~~~ <source>: In instantiation of 'void MISC<T>::add() [with T = int]': <source>:13:10: required from here <source>:8:39: error: no matching function for call to 'MISC<int>::addVecVals<(&((MISC<int>*)this)->MISC<int>::vec1)>()' 8 | void add(void) { addVecVals<&vec1>(); } | ~~~~~~~~~~~~~~~~~^~ <source>:7:26: note: candidate: 'template<int* vc> void MISC<T>::addVecVals() [with T* vc = vc; T = int]' 7 | template<T* vc> void addVecVals(){} | ^~~~~~~~~~ <source>:7:26: note: template argument deduction/substitution failed: <source>:8:34: error: '&((MISC<int>*)this)->MISC<int>::vec1' is not a valid template argument of type 'int*' because '((MISC<int>*)this)->MISC<int>::vec1' is not a variable 8 | void add(void) { addVecVals<&vec1>(); } | ^~~~ But for C++98, C++11, C++14, we get: <source>: In member function 'void MISC<T>::add()': <source>:8:22: error: parse error in template argument list 8 | void add(void) { addVecVals<&vec1>(); } | ^~~~~~~~~~~~~~~~~