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 03-Feb-01, Alexandre Oliva wrote:
> 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.
 
I see.

It works. Thank you.

I'm so sorry for flagging this as a bug. I should have used the mailing lists
instead. How can I remove my bug report?


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