This is the mail archive of the gcc@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]

RE: Casting Overloaded Function Pointer Problem...


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


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