Hi, I tried to compile the following program, but I got the following error. Is it a bug of GCC? Has it been fixed in a newer version GCC. g++ -Wall -W -pedantic -g -c -o main-g.o main.cc main.cc:57: internal compiler error: in write_type, at cp/mangle.c:1651 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. For Debian GNU/Linux specific bug reporting instructions, see <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>. Preprocessed source stored into /tmp/ccEcnj4W.out file, please attach this to your bugreport. Currently, I'm using g++ of the following version. g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Thanks, Peng #include <boost/typeof/typeof.hpp> #include <iostream> namespace A { template <typename T> class X { public: X() { } X(T t) : _t(t) { } const T &the_t() const { return _t; } private: T _t; }; template <typename T1, typename T2> struct multiply_traits; template <typename T1, typename T2> struct multiply_traits<X<T1>, T2> { typedef X<T1> result_type; }; template <typename T1, typename T2> typename multiply_traits<X<T1>, T2>::result_type operator*(const X<T1> &x, const T2 &t) { return X<T1>(x.the_t() * t); } } namespace B { template <typename T> class Y { public: Y(T t) : _t(t) { } const T &the_t() const { return _t; } private: T _t; }; template <typename T1, typename T2> //Y<typename A::multiply_traits<T1, T2>::result_type> Y<BOOST_TYPEOF(T1() * T2())> operator*(const Y<T1> &y, const T2 &t) { return Y<T1>(y.the_t() * t); } } int main () { A::X<int> x(2); B::Y<A::X<int> > y(x); std::cout << (x * 3).the_t() << std::endl; std::cout << (y * 5).the_t().the_t() << std::endl; }