This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/1841: Incorrect error: invalid use of member '' in staticmember function
- To: "'Neil Booth'" <neil at daikokuya dot demon dot co dot uk>
- Subject: Re: c++/1841: Incorrect error: invalid use of member '' in staticmember function
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 03 Feb 2001 15:35:57 -0200
- Cc: Martin Sebor <sebor at roguewave dot com>, Jean-Bernard Delva <JeanBernard dot Delva at trisignal dot com>, gcc-gnats at gcc dot gnu dot org, Normand Barriere <Normand dot Barriere at trisignal dot com>, gcc-bugs at gcc dot gnu dot org
- Organization: GCC Team, Red Hat
- References: <D8E12241B029D411A3A300805FE6A2B994C187@montreal.eicon.com><3A7B53E2.4D628912@roguewave.com><20010203100038.A6712@daikokuya.demon.co.uk>
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