This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
- From: "nicolas dot burrus at lrde dot epita dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Aug 2003 15:38:27 -0000
- Subject: [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
- References: <20030805101134.11804.nicolas.burrus@lrde.epita.fr>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11804
------- Additional Comments From nicolas dot burrus at lrde dot epita dot fr 2003-08-27 15:38 -------
Sorry, I wasn't clear. The problem is that B and C are empty classes and only
have default copy contructors (otherwise it could be fine to warn even if B
and C are empty).
I'm not familiar with gcc internals, but here is an extract of the source, in
gcc/cp/init.c line 659 (on mainline):
if (extra_warnings && !arguments
&& DECL_COPY_CONSTRUCTOR_P (current_function_decl)
&& TYPE_NEEDS_CONSTRUCTING (BINFO_TYPE (subobject))
&& TYPE_HAS_CONSTRUCTOR (BINFO_TYPE (subobject)))
warning ("base class `%#T' should be explicitly initialized in the "
"copy constructor",
BINFO_TYPE (subobject));
I think the problem comes from TYPE_NEEDS_CONSTRUCTING, which can be true even
if the class is empty if there is virtual inheritance or virtual functions
into it. The second case seems to corresponds to PR c++/5645.
I think the warning should be conditioned by a a predicate like
CLASSTYPE_NEARLY_EMPTY_P(). I don't reopen the bug myself since I may be wrong
though.