Casting Overloaded Function Pointer Problem...

Tom Zagotta tom@zagotta.cncdsl.com
Tue Sep 12 14:22:00 GMT 2000


Hi Don,

>>If I compile the above with the Sun CC compiler, I get no complaints
>>or warnings.  When I compile it with g++ (gcc version 2.95.2 19991024
>>(release)) I get the following error messages:

Your code is essentially asking GCC to convert the pointer to the member
function into a p-to-m-f of the base class.  If I'm interpreting this
correctly, according to the C++ Standard, section 13.4, this is not allowed:

	[Note: there are no standard conversions (clause 4) of one
pointer-to-function type into another. In particular, even if B is a public
base of D, we have
	D* f();
	B* (*p1)() = &f; // error
	void g(D*);
	void (*p2)(B*) = &g; // error
	-end note]

Therefore, I think GCC may be right in complaining about this code.

Regards,

Tom Zagotta



More information about the Gcc mailing list