From: cliff@cs.cornell.edu (Cliff Krumvieda)
Subject: Incorrect and internal compiler errors with g++-2.3.3 on sparcs
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 29 Dec 1992 04:56:09 GMT

Howdy:

We're running g++-2.3.3 on sparcs and SunOS 4.1.1; g++ is producing
some strange output on the two programs below.

######################################################################
######################################################################

bug.C:
======================================================================
#include <stream.h>

template<class T> 
class X{
  T ick;
public:
  X(T j){ ick = j;}
  X(X& x){ ick = x.ick;}
  T get(){ return ick; };
};

void zook ( X<char> y) {
  cout << y.get() << "\n";
}

main () {
  X<char> xc('a');
  zook(xc);
}
======================================================================

Compiling yields:

======================================================================
[~/bug/samuel] gnu% g++ -v bug.C
Reading specs from /usr/local/gnu/gcc-2.3.3/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/specs
gcc version 2.3.3
 /usr/local/gnu/gcc-2.3.3/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/cpp -lang-c++ -v
-undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__
-D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bug.C /usr/tmp/cca26400.i
GNU CPP version 2.3.3 (sparc)
 /usr/local/gnu/gcc-2.3.3/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/cc1plus /usr/tmp/cca26400.i -quiet -dumpbase bug.cc -version -o /usr/tmp/cca26400.s
GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
bug.C: In function `int  main ()':
bug.C:18: no constructor named `X' in visible scope
[~/bug/samuel] gnu%
======================================================================

However, it appears to me that X is in line 18's scope; indeed, AT&T's
CC compiler has no problem with bug.C.

######################################################################
######################################################################

bug2.C:
======================================================================
#include <stream.h>

template<class T> 
class X{
  T ick;
public:
  X(T j){ ick = j;}
  X(X& x){ ick = x.ick;}
  T get(){ return ick; };
};

template<class T>
void zook ( X y) {
  cout << y.get() << "\n";
}

main () {
  X<char> xc('a');
  zook(xc);
}
======================================================================

Compiling yields:

======================================================================
[~/bug/samuel] gnu% g++ -v bug2.C
Reading specs from /usr/local/gnu/gcc-2.3.3/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/specs
gcc version 2.3.3
 /usr/local/gnu/gcc-2.3.3/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/cpp -lang-c++ -v
-undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__
-D__sun__ -D__unix__ -D__sparc -D__sun -D__unix bug2.C /usr/tmp/cca26411.i
GNU CPP version 2.3.3 (sparc)
 /usr/local/gnu/gcc-2.3.3/lib/gcc-lib/sparc-sun-sunos4.1/2.3.3/cc1plus /usr/tmp/cca26411.i -quiet -dumpbase bug2.cc -version -o /usr/tmp/cca26411.s
GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
bug2.C:13: parse error before `)'
bug2.C: In function `int  main ()':
bug2.C:19: Internal compiler error.
bug2.C:19: Please report this to `bug-g++@prep.ai.mit.edu'.
[~/bug/samuel] gnu%
======================================================================

Thanks.

						--Cliff Krumvieda



Newsgroups: gnu.g++.bug