Re: access to static data member fails with indirect ptr

2011-01-04 Thread Jonathan Wakely
On 4 January 2011 14:11, Klaus Rudolph wrote: > >> > Is my code wrong >> >> Yes.  You need to define A::x. > > Grrr... so stupid! :-) > > Yes, you are right. I stumbled that only a few lines generates an error. Yes, > the compiler optimize them out if the access is direct. With -O3 > it compiles a

Re: access to static data member fails with indirect ptr

2011-01-04 Thread Klaus Rudolph
> > Is my code wrong > > Yes. You need to define A::x. Grrr... so stupid! :-) Yes, you are right. I stumbled that only a few lines generates an error. Yes, the compiler optimize them out if the access is direct. With -O3 it compiles and links without errors also without having const int A::x

Re: access to static data member fails with indirect ptr

2011-01-04 Thread Andrew Haley
On 01/04/2011 12:49 PM, Klaus Rudolph wrote: Is my code wrong Yes. You need to define A::x. Add this line: const int A::x; If the code is wrong, I expect a compiler error not a linker message! No, because A::x might be defined in another translation unit. Andrew.