This is the mail archive of the gcc-prs@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 static member function


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

From: Jean-Bernard Delva <JeanBernard.Delva@trisignal.com>
To: 'Neil Booth' <neil@daikokuya.demon.co.uk>
Cc: 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 static
	 member function
Date: Fri, 2 Feb 2001 19:01:53 -0500 

 > In my experience MSVC compiling something tells you very little about
 > its correctness, unless you're talking about -ve correlations :-)
 
 Agreed.
 
 That is why I compiled it with the Diab compiler (a well-repected compiler
 for embedded systems) and I get the same results.
  
 > > struct X
 > > {
 > >     static int X::* foo () { return &x; };
 > > 
 > >     int x;
 > > };
 > 
 > Maybe you could explain what this means?  I don't think it has a
 > meaning.  If a member function is static, it applies to the class as a
 > type, and not any specific instance.  So the 'x' of which instance are
 > you trying to return a pointer to?
 
 I understand that this construct is bordering on the isoteric but we need
 code that uses this. And after analysis, it seems correct.
 
 Since the static function foo returns a pointer to the data member x, it is
 only an offset into the structure. And this offset cannot be used without a
 structure instance. So a 'this' isn't really necessary in this case.
 
 Ex:
 
 int main ()
 {
     int X::* p, x;
     X Object;
 
     p = X::foo ();
 
     x = Object.*p;
 
     return 0;
 }
 
 If I understand pointer to members correctly, this is the way to use them
 (.* and ->*). That is why I think our construct is ok and safe in a static
 function. Other compilers seem to think so.
 
 I hope this makes my case more clear.
 
 Jean-Bernard Delva

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