This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Internal compiler error 364


I found an internal compiler error during the develiopement of the
aiclient for freeciv. Heres the compiler output and source for a
cleaned up part of code. I don't know if it is legal c++ code and I
see the problems of using references there. Further down I made a
Version of the same code that uses pointers. That one works as wanted,
but for obvious reasons I hate pointers. :) Whats a legal and nice way
of doing this?

fphp16:~/share/new> g++ internal_compiler_error_364.cc

internal_compiler_error_364.cc: In function `int main()':
internal_compiler_error_364.cc:26: warning: initialization of
non-const reference `class fooBase &' from rvalue `foo1'
/opt/share/include/g++/stl_vector.h: In method `void vector<fooBase
&,__default_alloc_template<false,0> >::push_back(class fooBase &const
&)':
/opt/share/include/g++/stl_vector.h:146: Internal compiler error 364.
/opt/share/include/g++/stl_vector.h:146: Please submit a full bug
report to `egcs-bugs@cygnus.com'.

fphp16:~/share/new> g++ --version

egcs-2.90.28 980423 (egcs-1.0.3 prerelease)

fphp16:~/share/new>

------------------] internal_compiler_error_364.cc [------------------

// Test for internal compiler error 364 with vectors

#include <iostream.h>
#include <vector>

class fooBase {
public:
	virtual void dofoo() { cout << "fooBase::dofoo()\n"; }
};

class foo1 : public fooBase {
public:
	void dofoo() { cout << "foo1::dofoo()\n"; }
};

class foo2 : public fooBase {
public:
	void dofoo() { cout << "foo2::dofoo()\n"; }
};

int main() {
	vector<fooBase &> foo;
	foo1 f1;
	foo2 f2;
	
	foo.push_back(f1);
	foo.push_back(f2);

	foo[0].dofoo();
	foo[1].dofoo();
};

------------------] internal_compiler_error_364.cc [------------------

--------------------] workaround_with_pointers.cc [-------------------

// Test for internat compiler error 364 with vectors (wrkaround) 

#include <iostream.h>
#include <vector>

class fooBase {
public:
	virtual void dofoo() { cout << "fooBase::dofoo()\n"; }
};

class foo1 : public fooBase {
public:
	void dofoo() { cout << "foo1::dofoo()\n"; }
};

class foo2 : public fooBase {
public:
	void dofoo() { cout << "foo2::dofoo()\n"; }
};

int main() {
	vector<fooBase *> foo;
	foo1 *f1 = new foo1;
	foo2 *f2 = new foo2;
	
	foo.push_back(f1);
	foo.push_back(f2);

	foo[0]->dofoo();
	foo[1]->dofoo();
};

--------------------] workaround_with_pointers.cc [-------------------

-------------------------] workaround output [------------------------

fphp16:~/share/new> workaround

foo1::dofoo()
foo2::dofoo()

-------------------------] workaround output [------------------------




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]