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]

Re: Member initialization of arrays of constants


Hi!

After a discussion on comp.std.c++ and quite some time spent on
reading the Standard and Bjarne Stroustrup's book, I feel sort of
brain-washed and tend to believe that this code must not compile
without errors because struct A contains uninitialized const members
that either require a constructor or cannot be initialized
explicitly:

struct A
{
	const char c[4];  // ill-formed
	const int i;      // requires constructor
};

class C
{
    static const A a;
};
	
const A C::a = { 'T','E','S','T', 2 };  // error! struct A is bad


In Stroustrup's "C++ Programming Language" 3rd Edition, see:

  10.4.2
  10.4.6.1
  10.4.6.2

In the C++ Standard see:

  8.5/9
  9/4
  9.2/4
  9.2/5

Conclusively,

Regards,
Mike

-- 
"I don't need luck. I got a system. I play all the odd red numbers."
- Danny Wilde (The Persuaders!)



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