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

Q: Assignment to pointer to member function oddities.


Hello;

Could somebody explain the behavior of egcs g++ (1.0.3)
compiling the following code, please:

$ cat test.cc
class B
{
public:
  virtual void foo();
};

typedef void (B::*BFunc)();

BFunc f1, f2, f3;

void boo(B* b)
{
  f1 = &B::foo; // OK
  f2 = b->foo;  // (14) ???
  f3 = &b->foo; // (15) ???
}

$ ~/local/bin/g++ -W -Wall -c test.cc
test.cc: In function `void boo(class B *)':
test.cc:14: warning: assuming pointer to member function is non-virtual
test.cc:15: assignment to `void (B::*)()' from `void (B::**)()'
$

I think (14) shouldn't compile at all. 
Don't know about (15).

Regards,
Sergei Organov


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