This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45829] Unary minus on static const class variable triggering linker error
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 29 Sep 2010 23:23:10 +0000
- Subject: [Bug c++/45829] Unary minus on static const class variable triggering linker error
- Auto-submitted: auto-generated
- References: <bug-45829-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45829
--- Comment #8 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2010-09-29 23:22:59 UTC ---
(In reply to comment #7)
> (In reply to comment #6)
> >
> > What is the point of allowing to initialize it then?
>
> Static const members declared with initializers can be used in constant
> expressions, see 9.4.2p4
...
> (N.B. Allowing an in-class initializer for non-integral and non-enumeration
> types in C++98 is a GCC extension. I believe it would be conforming, but is
> not required, for "-a" to be evaluated at translation time, without requiring a
> definition of "a".)
But -a (or 0.0-a) is not a constant expression, so having an in-class
initializer seems suspicious, couldn't we warn at least? What happens if the
definition is initialized to a different value?