From: enelson@rees.slac.stanford.edu (Eric M. Nelson)
Subject: (2.3.1 and 2.3.3?) Inconsistent return type for a template constructor
 - fatal signal 10.
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 11 Jan 1993 06:25:34 GMT

The following two cases compile: In the first case the methods are  
defined in the class declaration.

--------------------------  Example 1  ----------------------------
template<class T> class vec{
  T *v;
  public:
  vec(int size){v=new T[size];}
  ~vec(){delete[] v;}
  };

vec<double> aVec(10);
-------------------------------------------------------------------

In the next case only the constructor is declared, and it is
defined outside the class declaration. It also compiles.

--------------------------  Example 2  ----------------------------
template<class T> class vec{
  T *v;
  public:
  vec(int size);
  };

template<class T> vec<T>::vec(int size){
  v=new T[size];}

vec<double> aVec(10);
-------------------------------------------------------------------

The following case doesn't compile. I added the destructor
(defined in the class declaration) to example 2.

--------------------  Example 3  (vec3.cc)  -----------------------
template<class T> class vec{
  T *v;
  public:
  vec(int size);
  ~vec(){delete[] v;}
  };

template<class T> vec<T>::vec(int size){
  v=new T[size];}

vec<double> aVec(10);
-------------------------------------------------------------------
rees> g++ -c -v vec3.cc
Reading specs from /usr/local/lib/gcc-lib/next/2.3.1/specs
gcc version 2.3.1
 /usr/local/lib/gcc-lib/next/2.3.1/cpp -lang-c++ -v -undef  
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dmc68000 -Dm68k -DNeXT  
-Dunix -D__MACH__ -D__ARCHITECTURE__="m68k" -D__mc68000__ -D__m68k__  
-D__NeXT__ -D__unix__ -D__MACH__ -D__ARCHITECTURE__="m68k"  
-D__mc68000 -D__m68k -D__NeXT -D__unix -D__MACH__  
-D__ARCHITECTURE__="m68k" vec3.cc /usr/tmp/cc011951.i
GNU CPP version 2.3.1 (68k, MIT syntax)
 /usr/local/lib/gcc-lib/next/2.3.1/cc1plus /usr/tmp/cc011951.i -quiet  
-dumpbase vec3.cc -version -o /usr/tmp/cc011951.s
GNU C++ version 2.3.1 (68k, MIT syntax) compiled by GNU C version  
2.3.1.
vec3.cc:6: inconsistent return types for method `vec' in class  
`vec<double>'
/usr/local/bin/gcc: Internal compiler error: program cc1plus got  
fatal signal 10

This error also occurs if I only declare the destructor (there is no  
definition of the destructor in the source file). And it occurs if I  
define the destructor outside of the declaration (similar to the  
definition of the constructor in examples 2 and 3). Also, I believe  
these problems also occur in 2.3.3:

rees> g++ -B${HOME}/Sources/gnu/gcc-2.3.3/ -v -c vec3.cc
Reading specs from  
/Net/apnext1/Users/enelson/Sources/gnu/gcc-2.3.3/specs
gcc version 2.3.1
 /Net/apnext1/Users/enelson/Sources/gnu/gcc-2.3.3/cpp -lang-c++ -v  
-undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dmc68000 -Dm68k  
-DNeXT -Dunix -D__MACH__ -D__ARCHITECTURE__="m68k" -D__mc68000__  
-D__m68k__ -D__NeXT__ -D__unix__ -D__MACH__ -D__ARCHITECTURE__="m68k"  
-D__mc68000 -D__m68k -D__NeXT -D__unix -D__MACH__  
-D__ARCHITECTURE__="m68k" vec3.cc /usr/tmp/cc012026.i
GNU CPP version 2.3.3 (68k, MIT syntax)
 /Net/apnext1/Users/enelson/Sources/gnu/gcc-2.3.3/cc1plus  
/usr/tmp/cc012026.i -quiet -dumpbase vec3.cc -version -o  
/usr/tmp/cc012026.s
GNU C++ version 2.3.3 (68k, MIT syntax) compiled by GNU C version  
2.3.3.
vec3.cc:6: inconsistent return types for method `vec' in class  
`vec<double>'
/usr/local/bin/gcc: Internal compiler error: program cc1plus got  
fatal signal 10

I hope this helps find a bug.
-Eric

Newsgroups: gnu.g++.bug