This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Internal compiler error.
- To: gcc at gcc dot gnu dot org
- Subject: Internal compiler error.
- From: Benjamin Scherrey <scherrey at innoverse dot com>
- Date: Sat, 24 Feb 2001 23:45:22 -0500
- Organization: Innoverse, Inc.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I've been fighting this error for a while and have gotten it down to a
relatively small sample. The attached code causes an internal compiler error
in g++ 2.95.2 under both x86 Linux 2.4.1-ac18 ( binutils 2.10.x ). and
CygwinNT 1.1.7. It compiles and runs as expected under Borland C++ for NT. Is
this a known bug? Is there a work-around for this? I'm really stuck here
cause Windows ain't my target environment! :-(
thanx & later,
Ben Scherrey
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8
iQA/AwUBOpiN5mj9nzX41wUgEQLZuwCgjRjp9fmfR+rhU0OtKbbLPhWDubMAoOHR
tJim2/h7Mo5DpJnXRiSN8JG2
=5ViE
-----END PGP SIGNATURE-----
//
// Any.cpp - Test Any type class development.
//
// GENERATES INTERNAL COMPILER ERROR in gcc 2.95.2
//
// Note - void* type is just for demo. Real code
// uses a ref-counted ptr class template.
//
#include <iostream>
#include <string>
#include <typeinfo>
using namespace std;
struct Any
{
Any( void ) : Value(0)
{ cout << "Default Any ctor." << endl; }
Any( const Any& a ) : Value( a.Value )
{ cout << "Copy Any ctor." << endl; }
template < typename Z >
Any( const Z& z ) : Value( new TContent< Z >( z ) )
{
cout << typeid( Z ).name() << " Any ctor: z = "
<< z <<"." << endl;
}
Any( const char* s ) : Value( new TContent< string >( s ) )
{ cout << "const char* Any ctor: s = " << s << "." << endl; }
protected:
struct Content
{
Content( void )
: Data(0), Type(0) {;}
Content( const Content& t )
: Data( t.Data ), Type( t.Type ) {;}
Content( void* d, const type_info* t )
: Data( d ), Type( t ) {;}
virtual ~Content( void ) {;}
virtual Content& operator=( const Content& t )
{ Data = t.Data; Type = t.Type; return *this; }
void* Data;
const type_info* Type;
};
template < typename T >
struct TContent : public Content
{
TContent( void )
: Content( new void*(0), &typeid( T ) ) {;}
TContent( const TContent& t )
: Content( t ) {;}
TContent( const T& t )
: Content( new T(t), &typeid( T ) ) {;} // INTERNAL ERROR!
virtual ~TContent( void ) {;}
};
Content* Value;
};
int main( void )
{
const char* X = "I'm a string!";
Any a("First try");
Any b( X );
Any c( (string( X )) );
Any d( 42 );
string S( X );
Any e( S );
return 0;
}
//
// eof( special.cpp )
//