following is the code that segfaults. when using the first version of "helper" it works nicely. #include <iostream> typedef char present_t; typedef struct { char a[2]; } absent_t; template <typename T> T& MakeT(); template <typename T> struct test { // template <typename U, int (U::*f)(int n) = &U::operator[]> // struct helper{}; template <typename U, int N = sizeof (MakeT<U>().operator[](0))> struct helper{}; template <typename U> static absent_t is_here(...); template <typename U> static present_t is_here(helper<U>*); enum { ret = (sizeof(is_here<T>(0)) == sizeof(present_t)) }; }; struct A { }; struct B { int operator[](int n) { return n; } }; struct X : public A { }; struct Y : public B { }; int main() { std::cout << "A has [] : " << test<A>::ret << std::endl; std::cout << "B has [] : " << test<B>::ret << std::endl; std::cout << "X:A has [] : " << test<X>::ret << std::endl; std::cout << "Y:B has [] : " << test<Y>::ret << std::endl; } g++ -W -Wall has_methode_in_hierarchy.cc has_methode_in_hierarchy.cc:21: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://bugs.gentoo.org/> for instructions. # g++ --version g++ (GCC) 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110, ssp-3.4.3.20050110-0, pie-8.7.7)
Will be included in the next 4.0.2 tarball. If upstream backports this to 3.4, I'll add it to 3.4.5 at that time.