https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86301
Bug ID: 86301 Summary: g++ does not mark declarations used in non-dependent types as referenced Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- The code is as follow: template<typename T> struct X1 { static void member() { T* x = 1; } }; template<void(*)()> struct instantiate { }; template<typename T> struct X2 { typedef instantiate<&X1<int>::member> i; }; clang++ accepts it, but g++ rejects it with a message: In instantiation of ‘static void X1<T>::member() [with T = int]’: required from here error:invalid conversion from ‘int’ to ‘int*’ [-fpermissive] static void member() { T* x = 1; } The code comes from https://bugs.llvm.org/show_bug.cgi?id=7079 A previous version of clang++ produces similar error message for this code, but was fixed.