Hi Guys,

Compiling and then executing this program:
#include <stdio.h>

class A {
public:
 virtual void get() { printf ("A\n"); }
};
class B:public A {
public:
 virtual void get() { printf ("B\n"); }
};
class C:public B {
};
int main (void)
{
 C c;
 C* p = &c;

 p->A::get();
 (p->A::get)();

 return 0;
}

Results in:

  A
  B

Being displayed, rather than:

  A
  A

As far as I can tell the parentheses around the class member access should not
change anything.

Cheers
  Nick


-- 
           Summary: Parenthesised indirection alters class member access
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nickc at redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to