This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/20547] undefined reference to "static const" fields of classes
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Mar 2005 14:03:43 -0000
- Subject: [Bug c++/20547] undefined reference to "static const" fields of classes
- References: <20050319065920.20547.Hu.YuehWei@gmail.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-19 14:03 -------
(In reply to comment #2)
> But according the standard, 'const static' data members of an intergral type can
> now be initialized _inside_ their class. In this case, the initialization is
> _also_ a definition, so _no_ further definitions are reuquired outside the class
> body.
No it is not a definition, a definition (or is it the other way around). Still this is invalid. Yes the compiler
is allowed to "optimize" the constant which is why it worked in 2.95.3 (well because the defintion of
push_back was wrong).
Oh, one more thing, the vector code is equivalent to (so you take the address):
struct T
{
static char const a = 3;
};
void
fff(const char &a){ }
int
main()
{
fff(T::a);
return 0;
}
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20547