crash when friend function defines template specialization

Ian Haggard ian@shellus.com
Tue Feb 24 09:20:00 GMT 1998


I'm enclosing a transcript in which I produce an internal compiler error that
is caused by the instantiation of a friend function which is defined in the
body of a template class.  The friend function is a specialization of a
function template.

This crash occurs both in gcc-2.8.0 and in egcs-1.0.0, so I'm sending the bug
report to both lists.

This was definitely a fun one to find, as the line number in my original
sources that was causing the crash was so far away from the line where the
internal compiler error was being reported :^)
-- 
Ian Haggard  ||  ian@shellus.com (work)  ||  IanHaggard@juno.com (home)
GNU/Linux -- "Oh, no, Mr Bill!" || #define employer_opinion !my_opinion
triton:tests% ~/pkg/egcs-1.0/sparc-sun-solaris2.5.1/bin/g++ bug.cc -UNO_CRASH -c -v
Reading specs from /////////////////////home/discovery4/ian/pkg/egcs-1.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/specs
gcc version egcs-2.90.21 971202 (egcs-1.00 release)
 /////////////////////home/discovery4/ian/pkg/egcs-1.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) -UNO_CRASH bug.cc /tmp/cca004BJ.ii
GNU CPP version egcs-2.90.21 971202 (egcs-1.00 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /home/discovery4/ian/pkg/egcs-1.0/include/g++
 /home/discovery4/ian/pkg/egcs-1.0/sparc-sun-solaris2.5.1/sparc-sun-solaris2.5.1/include
 /home/discovery4/ian/pkg/egcs-1.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/include
 /usr/include
End of search list.
 /////////////////////home/discovery4/ian/pkg/egcs-1.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.21/cc1plus /tmp/cca004BJ.ii -quiet -dumpbase bug.cc -version -o /tmp/cca004BJ.s
GNU C++ version egcs-2.90.21 971202 (egcs-1.00 release) (sparc-sun-solaris2.5.1) compiled by GNU C version 2.7.0.
bug.cc:20: Internal compiler error.
bug.cc:20: Please submit a full bug report to `egcs-bugs@cygnus.com'.
triton:tests% ~/pkg/gcc-2.8.0/sparc-sun-solaris2.5.1/bin/g++ bug.cc -UNO_CRASH -c -v
Reading specs from ////////////////////home/discovery4/ian/pkg/gcc-2.8.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/2.8.0/specs
gcc version 2.8.0
 ////////////////////home/discovery4/ian/pkg/gcc-2.8.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/2.8.0/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=8 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) -UNO_CRASH bug.cc /tmp/cca004Bc.ii
GNU CPP version 2.8.0 (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /home/discovery4/ian/pkg/gcc-2.8.0/include/g++
 /home/discovery4/ian/pkg/gcc-2.8.0/sparc-sun-solaris2.5.1/sparc-sun-solaris2.5.1/include
 /home/discovery4/ian/pkg/gcc-2.8.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/2.8.0/include
 /usr/include
End of search list.
 ////////////////////home/discovery4/ian/pkg/gcc-2.8.0/sparc-sun-solaris2.5.1/lib/gcc-lib/sparc-sun-solaris2.5.1/2.8.0/cc1plus /tmp/cca004Bc.ii -quiet -dumpbase bug.cc -version -o /tmp/cca004Bc.s
GNU C++ version 2.8.0 (sparc-sun-solaris2.5.1) compiled by GNU C version 2.7.0.
bug.cc:20: Internal compiler error.
bug.cc:20: Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.
triton:tests% ~/pkg/egcs-1.0/sparc-sun-solaris2.5.1/bin/g++ bug.cc -DNO_CRASH -c
triton:tests% ~/pkg/gcc-2.8.0/sparc-sun-solaris2.5.1/bin/g++ bug.cc -DNO_CRASH -c
triton:tests% cat bug.cc
template<class X>
class Deleter {
  X* px;
public:
  ~Deleter()
  { delete px; }
};

template<class T>
inline void my_friend_function(const T& t);

template <int dim>
struct MyClassHelper {
  friend void my_friend_function
  <>
  (const  MyClassHelper<dim> & t)
#ifdef NO_CRASH
  ;
#else
  {}
#endif
};


template<class T,int dim>
class MyClass {
public:
  void foo(MyClassHelper<dim> si) const;
};

struct MyT {};

Deleter< MyClass<MyT,3> > MakeMyClass();

void UseMyClass() {
  Deleter< MyClass<MyT,3> > xyPartition(MakeMyClass());
}
triton:tests% 



More information about the Gcc-bugs mailing list