🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Gail Slemon Wed, 12 Aug 1992 16:34
gcc optimization bug
#931
Author: Gail Slemon
Date: Wed, 12 Aug 1992 16:34
61 lines
1602 bytes
To: >Internet:bug-gcc@prep.ai.mit.edu
Hi!
	Found an optimizer bug and isolated it using
the following code.  This was done on a Sun SPARC
using gcc-2.2.2 and libg++-2.1.  The code works
when compiling without the "O" or "O2" switches
but does not work with optimization.  It seems
that the non-virtual function, printa, is
treated as a virtual function and the program
does a core dump when a nil pointer tries to
invoke the function.
---------------------
#include <iostream.h>
#define nil 0

class temp {
public:
	int a;
	temp();
	virtual void testa (temp*);

	void printa(ostream& os);
};

temp::temp(){
	a=0;
}

void temp::testa(temp* tmp){
	cout << tmp->a;
	cout << "Survived test\n";
}

void temp::printa(ostream& os){
	os << "this is a test";

	if (this == nil) {
		os << "This is nil\n";
	}
	else
	{
		this -> testa(this);
		os << "This is not nil\n";
	}
}

main(){
	temp aa;
	temp* aptr = nil;

	aa.printa(cout);
	aptr->printa(cout);
}
-----------------------
Is there a way to be on your mailing list with
my compuserve address?

     Thanks again!!!
     Gail Slemon, Expersoft
     phone #s: (619) 546-4100
               (800) 755-7011
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads