public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nicolas dot burrus at lrde dot epita dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
Date: Wed, 27 Aug 2003 15:38:00 -0000	[thread overview]
Message-ID: <20030827153827.24731.qmail@sources.redhat.com> (raw)
In-Reply-To: <20030805101134.11804.nicolas.burrus@lrde.epita.fr>

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.


  parent reply	other threads:[~2003-08-27 15:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-05 10:11 [Bug c++/11804] New: " gcc-bugzilla at gcc dot gnu dot org
2003-08-05 13:55 ` [Bug c++/11804] " pinskia at physics dot uc dot edu
2003-08-27 14:32 ` lerdsuwa at gcc dot gnu dot org
2003-08-27 15:38 ` nicolas dot burrus at lrde dot epita dot fr [this message]
2003-08-27 16:01 ` bangerth at dealii dot org
2003-08-28 14:49 ` pinskia at gcc dot gnu dot org
2004-02-18 10:38 ` okohlbacher at gmx dot de
2004-04-27  2:53 ` pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030827153827.24731.qmail@sources.redhat.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).