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


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