This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

Re: c++/9927: Compiler requires definition of static member constants


> >     The compiler is allowed to require that you provide a
> >     definition of static member constants. I think, they are
> >     even mandated. That's exactly what happens in your case.
> >
> >     You'll notice, however, that if you compile with optimization,
> >     the compiler actually replaces references to these
> >     variables by their values, which is probably what you
> >     want.
> 
> Why, then, does the program compile and link if the "?:" construct is 
> replaced with a "if (...) else (...)", even if the static const int's are 
> not defined.

By chance? The standard requires you to provide a definition of the 
variable, so the compiler's free to make use of this requirement at its 
own descretion. This might include certain contexts but not others.

> I thought this was a special case for const int's.

No, the special case is that you can give an initializer. But you can't 
omit the definition.

W.

-------------------------------------------------------------------------
Wolfgang Bangerth             email:            bangerth at ticam dot utexas dot edu
                              www: http://www.ticam.utexas.edu/~bangerth/



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