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: Martin Sebor <sebor at roguewave dot com>
- Subject: Re: c++/1841: Incorrect error: invalid use of member '' in staticmember function
- From: 'Neil Booth' <neil at daikokuya dot demon dot co dot uk>
- Date: Sat, 3 Feb 2001 10:00:38 +0000
- Cc: 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
- References: <D8E12241B029D411A3A300805FE6A2B994C187@montreal.eicon.com> <3A7B53E2.4D628912@roguewave.com>
Martin Sebor wrote:-
> > > > struct X
> > > > {
> > > > static int X::* foo () { return &x; };
> > > >
> > > > int x;
> > > > };
> The code is incorrect, the type of the result is int*, the type
> returned from the function is int X::*. Here's the relevant text:
>
> 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. In the
> first case, if the type of the expression is ``T,'' the type of the
> result is ``pointer to T.'' In particular, the address of an object
> of type ``cv T'' is ``pointer to cv T,'' with the same
> cv-qualifiers. For a qualified-id, if the member is a static member
> of type ``T'', the type of the result is plain ``pointer to T.'' 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.'
Hi Martin,
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?
Neil.