🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #2164

Is this a G++ bug?

#2164
From: David S. Masterson
Date: Thu, 11 Jan 1990 23:59
43 lines
1437 bytes
Below is a short program that exploits what I think is a bug in the G++
compiler.  I am using g++ 1.36.1 on SunOS 3.5.  The bug calls a method that
requires an (alpha*) when a (void*) is passed to it.  I would have thought
that the compiler should flag this as a function call for which an invalid
argument type was passed.  Am I wrong?

--------Code begins--------
#include <stream.h>

class alpha {
	static int	x = 0;

public:
	alpha() { x = x + 1; }
	~alpha() {}

	void print(alpha*);
};

void alpha::print(alpha* n) {
	cout << "X = " << x << " ";
	if (n != 0)
		n->print((void*) 0);
	cout << ";";
}

int main(int argc, char *argv[])
{
	alpha	test1;

	test1.print((void*) 0);

	alpha	*test2 = new alpha;

	test1.print(test2);
	cout << "\n";
}
--
===================================================================
David Masterson					Consilium, Inc.
uunet!cimshop!davidm				Mt. View, CA  94043
===================================================================
"If someone thinks they know what I said, then I didn't say it!"
Technical Details
Message-ID: <CIMSHOP!DAVIDM.90Jan11155927@uunet.UU.NET>
Path: arc1-ca.pugleaf.net!utzoo!telly!philmtl!uunet!cimshop!davidm

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!philmtl!uunet!cimshop!davidm
From: cimshop!davidm@uunet.UU.NET (David S. Masterson)
Newsgroups: gnu.g++.bug
Subject: Is this a G++ bug?
Message-ID: <CIMSHOP!DAVIDM.90Jan11155927@uunet.UU.NET>
Date: 11 Jan 90 23:59:27 GMT
Sender: davidm@cimshop.UUCP
Distribution: gnu
Organization: Consilium Inc., Mountain View, California.
Lines: 43