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

Neil Booth neil@daikokuya.demon.co.uk
Fri Feb 2 14:25:00 GMT 2001


jb@trisignal.com wrote:-

> The compiler rejects taking the pointer to a class data member in a
> static function.  CodeSourcery's Online Test Compilation gives the
> same error.  The same code compiles with the Diab MSVC compilers
> with -strict-ansi enabled.

In my experience MSVC compiling something tells you very little about
its correctness, unless you're talking about -ve correlations :-)

> 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?

Neil.


More information about the Gcc-bugs mailing list