This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19968] [3.3/3.4/4.0/4.1 Regression] Warning omitted for non-derived classes
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Mar 2005 21:54:41 -0000
- Subject: [Bug c++/19968] [3.3/3.4/4.0/4.1 Regression] Warning omitted for non-derived classes
- References: <20050215012640.19968.reichelt@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2005-03-02 21:54 -------
Correct. The class without inheritance doesn't need a constructor
since objects of this type can be initialized using a brace-enclosed
list. The class with inheritance is not POD, so it can't be initialized
that way and needs a constructor. This should demonstrate this:
-----------------
struct B {};
struct A1 : B { const int i; };
struct A2 { const int i; };
A1 a1 = { 1 }; // not ok
A2 a2 = { 1 }; // ok
-----------------
g/x> /home/bangerth/bin/gcc-3.4.4-pre/bin/c++ -W -Wall -ansi -pedantic -c x.cc
x.cc:3: warning: non-static const member `const int A1::i' in class without a
constructor
x.cc:6: error: `a1' must be initialized by constructor, not by `{...}'
This is therefore not a bug but correct behavior.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19968