Purpose of -Wno-pmf-conversionsClass Has No Vtable)

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Sat Sep 18 06:50:00 GMT 1999


> Say `used to'; just `used' is ungrammatical.  And one more sentence
> explaining that a virtual function in the derived class can be called
> with a pointer to member of the base class wouldn't hurt.
> 
> Thanks!

Installed. Unfortunately, I found that g++.mike/p10769a.C and
g++.mike/p11012.C break with the patch, because they now run into the
error

object missing in `&Foo::f'

To me, there is a genuine error in the test cases. The code is
ill-formed; you cannot convert a pointer-to-member-function to
pointer-to-function.

Before restoring the old behaviour (i.e. fixing it to pass these tests
again), I'd like to know whether this is an official extension of g++:

A) A pointer-to-member can be converted to a pointer-to-function with
   the same signature.

In p10769a.C, the pointer is later converted to a function pointer
taking the "this" argument explicitly. So perhaps the extension is
rather

B) A pointer-to-member-function can be converted to a
   pointer-to-function with the same signature, but an explicit
   first "this" argument.

To me, either extension looks wrong. It works only if there is no
pointer adjustment, and apparently, the current implementation has a
number of limitations (see the XFAILs). Also, it seems to work for
PMF constants only, not for variables of PMF type.

Furthermore, the same effect can be achieved in a more well-defined
way, by writing constructs like

  p.__pfn_or_delta2.__pfn

(using knowledge about the internal representation of PMFs)

I'm willing to correct this in a number of different ways: Either
complete the extension to a meaningful semantics (perhaps with
well-known restrictions), or to drop the extension entirely.

Any guidance appreciated,
Martin


More information about the Gcc-bugs mailing list