[gnu.g++.bug] Is this a G++ bug?

davidm@uunet.UU.NET (David S. Masterson) (01/12/90)

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!"

tiemann@AI.MIT.EDU (Micheal Tiemann) (01/14/90)

When I did the type rules for GNU C++, I thought that cfront was wrong
not to let void* convert to T* and vice-versa.  I now think that ANSI
was wrong, so in GNU C++ version 2.0 (after 1.37.0), I will fix this.

Michael