Hi, The following short code example produces an internal compiler error with g++ 4.4.0.
struct Void {}; template <class R> struct FunType { typedef R ResultType; }; struct WrongNumberOfSigArgs {}; template <typename R> struct CFunType { template <class Dummy1=Void, class Dummy2=Void> struct Sig : public FunType<WrongNumberOfSigArgs> {}; template <class Dummy> struct Sig<Void,Dummy> : public FunType<R> {}; }; struct Dummy { template <typename F> typename F::template Sig<>::ResultType operator()(F const& f) const { return typename F::template Sig<>::ResultType(0); } }; struct Gen: public CFunType<int> { int operator()() const {return 0;} Gen() {} }; int myfunction() { return Dummy()(Gen()); } int main() { myfunction(); } I believe the above code is invalid. But g++ should stop with an error report rather than an internal compiler error. To make the code valid, in Dummy, replace the two instances of Sig<> with Sig<Void>. (With g++ 4.3.3 the code compiles fine -- which it shouldn't -- and seems to choose the wrong member template.) The commandline I ran, and associated output is as follows. $ LD_LIBRARY_PATH=/usr6/ausdev/32/gcc/lib: /usr6/ausdev/32/gcc/bin/g++ -v templatebug.cc Using built-in specs. Target: i686-pc-linux-gnu Configured with: ./configure --prefix=/usr6/ausdev/32/gcc --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ --with-gmp=/usr6/ausdev/tools/build/gmp --with-mpfr=/usr6/ausdev/tools/build/mpfr --with-gnu-as --with-as=/usr6/ausdev/32/gcc/bin/as Thread model: posix gcc version 4.4.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic' /usr6/ausdev/32/gcc/libexec/gcc/i686-pc-linux-gnu/4.4.0/cc1plus -quiet -v -D_GNU_SOURCE templatebug.cc -quiet -dumpbase templatebug.cc -mtune=generic -auxbase templatebug -version -o /tmp/ccKj2izO.s ignoring nonexistent directory "/usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../include/c++/4.4.0 /usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../include/c++/4.4.0/i686-pc-linux-gnu /usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../include/c++/4.4.0/backward /usr/local/include /usr6/ausdev/32/gcc/include /usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/include /usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/include-fixed /usr/include End of search list. GNU C++ (GCC) version 4.4.0 (i686-pc-linux-gnu) compiled by GNU C version 4.4.0, GMP version 4.2.4, MPFR version 2.4.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: cdc0e2c063f6091375cab171c4ed59f5 templatebug.cc: In function int myfunction(): templatebug.cc:26: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. -- Summary: member template specialization causes ICE Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mark at austrics dot com dot au http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40808