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]

Re: c++/1841: Incorrect error: invalid use of member '' in staticmember function


On Feb  3, 2001, "'Neil Booth'" <neil@daikokuya.demon.co.uk> wrote:

> Martin Sebor wrote:-

>> > > > struct X { static int X::* foo () { return &x; }; int x; };

>> 5.3.1, p2: "The result of the unary & operator is a pointer to its
>> operand. The operand shall be an lvalue or a qualified-id. [...] 
>> For a qualified-id, [...] If the member is a nonstatic member of
>> class C of type T, the type of the result is ``pointer to member of
>> class C of type T.'

> You've confused me now.  According to the last few words of what you
> quoted, I read that the type of "&x" is int X::*.  That is the type
> being returned in the function prototype.  So what's wrong?

x is neither an lvalue nor a qualified-id.  To get a
pointer-to-member, the C++ Standard requires &X::x.  Just &x won't do.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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