This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9927: Compiler requires definition of static member constants
- From: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- To: Andrew Bell <acbell at iastate dot edu>
- Cc: gcc-bugs at gcc dot gnu dot org, <gcc-gnats at gcc dot gnu dot org>
- Date: Mon, 3 Mar 2003 16:28:53 -0600 (CST)
- Subject: 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/