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]

[Bug c++/20547] undefined reference to "static const" fields of classes


------- 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


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