This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Member initialization of arrays of constants
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: Member initialization of arrays of constants
- From: Michael Schwendt <mschwendt at web dot de>
- Date: Wed, 9 Aug 2000 23:53:27 +0200 (CEST)
- Organization: Private Linux Intranet
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!)