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

'Neil Booth' neil@daikokuya.demon.co.uk
Sun Apr 1 00:00:00 GMT 2001


The following reply was made to PR c++/1841; it has been noted by GNATS.

From: 'Neil Booth' <neil@daikokuya.demon.co.uk>
To: Martin Sebor <sebor@roguewave.com>
Cc: Jean-Bernard Delva <JeanBernard.Delva@trisignal.com>,
	gcc-gnats@gcc.gnu.org,
	Normand Barriere <Normand.Barriere@trisignal.com>,
	gcc-bugs@gcc.gnu.org
Subject: Re: c++/1841: Incorrect error: invalid use of member '' in staticmember function
Date: Sat, 3 Feb 2001 10:00:38 +0000

 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.


More information about the Gcc-prs mailing list