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: "Hu dot YuehWei at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Mar 2005 07:59:18 -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 Hu dot YuehWei at gmail dot com 2005-03-20 07:59 -------
so the "... = 3;" initialization statement below is a definition or a declaration?
According to the C++ standard, its a definition.
Should the compiler allocate a memory space for it?
struct T
{
static char const a = 3;
};
And...
If I need to allocate memory spaces for it manually, why the standard explicitly
specify this kind of coding style?
========================
struct T
{
static char const a = 3; /* standard explicity specify that the initialization
& definition can be put here. */
};
char const T::a; /* If I need this line of codes, then the initialization above
should be a declaration, not a definition. But a declaration can be initialized? */
========================
struct T
{
static char const a;
};
char const T::a = 3;
========================
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20547