http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53225

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-04 
21:06:34 UTC ---
Also, see the code I provided at SO:
http://stackoverflow.com/a/10449212/981959
That demonstrates that a base class member function knows nothing about the
derived class.

here's another:

#include <iostream>

void g(int i) { std::cout << "int: " << i << '\n'; }
void g(short i) { std::cout << "short: " << i << '\n'; }

struct A
{
  static const int i = 1;
  typedef int int_type;

  void f() {
    int_type j = i;
    g(j);
  }
};

struct B : A
{
  static const short i = 0;
  typedef short int_type;
};

int main()
{
  B b;
  b.f();
}

A::f() calls g(int) and prints 1, not g(short) printing 0, because in A::f()
int_type is int and i has the value 1.

That's a normal member function, not operator new.  You could make A::f()
static and the result will be exactly the same.

Does that help?

Reply via email to