This is the mail archive of the gcc-patches@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: g++.bob/inherit1 (Was: wrong error for G++ test suite case)


Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:

> I believe David is right here (as usual :-).

He probably is, but there's a paragraph that made me unsure about
whether this is correct or not, [expr.prim]:

11An id-expression that denotes a nonstatic  data  member  or  nonstatic
  member function of a class can only be used:
[snipped unrelated cases]
  --in  the  body  of  a nonstatic member function of that class or of a
    class derived from that class (_class.mfct.nonstatic_), or
[...]

If we understand that C::foo denotes a nonstatic member function of
class C, the usage is invalid.  However, if we understand that C::foo
denotes a member of class A, which seems the correct interpretation,
then this usage is valid, although a bit strange...


An equivalent example follows:

struct A { void foo(); };
struct C : A {};
struct B : A { void bar() { C::foo(); } };

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



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