http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57831
Bug ID: 57831 Summary: pointer to member function inaccessible through using statement (or ICE) Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: t-gcc-bugzilla at snowelm dot com g++ 4.8.1 rejects the following code saying "B<T>::base::f is inaccessible". I believe the code is valid (and compiled without error by Clang). Moreover, when I use the trunk head g++, it crashes with ICE. ---------------------------- struct A { void f(); }; template <class T> struct B : T { typedef T base; using base::f; // If I write "using B<T>::f" it's ok void g( ) { B<T>::f(); // This is OK as expected (this->*&T::f)(); // This is also OK (this->*&B<T>::f)(); // This causes error } }; template struct B< A >; ---------------------------- It is strange to see "inaccessible" error, since everything in the code is public. The oldest g++ in my environment (g++ 4.4) also rejects the code. Coupiler output for g++ 4.8.1 and g++ trunk are attached below Possibly related to PR 57658 or PR 53549. ------------------------------ $ g++-4.8 -v Using built-in specs. COLLECT_GCC=g++-4.8 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr/local --program-suffix=-4.8 --enable-languages=c,c++,lto Thread model: posix gcc version 4.8.1 (GCC) $ g++-4.8 hoge.ii hoge.ii: In instantiation of 'void B<T>::g() [with T = A]': hoge.ii:13:17: required from here hoge.ii:6:14: error: 'using B<T>::base::f' is inaccessible using base::f; ^ hoge.ii:10:13: error: within this context (this->*&B<T>::f)(); ^ hoge.ii:10:10: error: pointer to member type 'B<T>::base' incompatible with object type 'B<A>' (this->*&B<T>::f)(); ------------------------------ $ g++-4.9 -v Using built-in specs. COLLECT_GCC=g++-4.9 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/usr/local --program-suffix=-4.9 --enable-languages=c,c++,lto Thread model: posix gcc version 4.9.0 20130705 (experimental) (GCC) $ g++-4.9 hoge.ii hoge.ii: In instantiation of 'void B<T>::g() [with T = A]': hoge.ii:13:17: required from here hoge.ii:10:13: internal compiler error: in tsubst_copy, at cp/pt.c:12616 (this->*&B<T>::f)(); ^ 0x59f08b tsubst_copy ../../gcc/cp/pt.c:12616 0x5b4bb9 tsubst_qualified_id ../../gcc/cp/pt.c:12013 0x58062b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:13684 0x57f906 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:13738 0x57e66b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/cp/pt.c:14013 0x5874f2 tsubst_expr ../../gcc/cp/pt.c:13429 0x587a4f tsubst_expr ../../gcc/cp/pt.c:12908 0x586f93 tsubst_expr ../../gcc/cp/pt.c:12894 0x587d64 tsubst_expr ../../gcc/cp/pt.c:13084 0x5858bc instantiate_decl(tree_node*, int, bool) ../../gcc/cp/pt.c:19157 0x5c14ff instantiate_pending_templates(int) ../../gcc/cp/pt.c:19256 0x5fd809 cp_write_global_declarations() ../../gcc/cp/decl2.c:4063 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. ------------------------------