public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor
@ 2003-08-05 10:11 gcc-bugzilla at gcc dot gnu dot org
  2003-08-05 13:55 ` [Bug c++/11804] " pinskia at physics dot uc dot edu
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2003-08-05 10:11 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Wrong warning about explicit initialization of base
                    class default constructor
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nicolas dot burrus at lrde dot epita dot fr
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

Fix:
I could not find in the documentation a -Wno-xxx flag disabling this warning.
------- Additional Comments From nicolas dot burrus at lrde dot epita dot fr  2003-08-05 10:11 -------
Considering the following code:

struct A {};

struct B : virtual public A {};

struct C : virtual public A {};

struct D : public B, public C 
{
  D(const D& d) {}
};

Here is the output of g++ (2.95, 3.0, 3.2, 3.3 and 3.4):

warning_base_class2.cc: In copy constructor `D::D(const D&)':
warning_base_class2.cc:9: warning: base class `struct B' should be explicitly 
   initialized in the copy constructor
warning_base_class2.cc:9: warning: base class `struct C' should be explicitly 
   initialized in the copy constructor

This seems odd since only default constructors are defined in B and
C. como -A and icc -Xc accepts this code without these warnings.

I noticed that this bug is quite close to PR c++/5645 (which seems to
have been reintroduced a while ago).

Environment:
System: Linux meissa 2.4.21 #1 Sat Jul 26 02:06:42 CEST 2003 i686 GNU/Linux
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /home/nes/work/lrde/ext/gcc/configure --prefix=/opt/gcc-3.4 --enable-languages=c,c++ : (reconfigured)

How-To-Repeat:
Compile the given code.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
  2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor gcc-bugzilla at gcc dot gnu dot org
@ 2003-08-05 13:55 ` pinskia at physics dot uc dot edu
  2003-08-27 14:32 ` lerdsuwa at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-05 13:55 UTC (permalink / raw)
  To: gcc-bugs

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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2003-08-05 13:55:37
               date|                            |


------- Additional Comments From pinskia at physics dot uc dot edu  2003-08-05 13:55 -------
I can confirm this on the mainline (20030805).


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
  2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor 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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2003-08-27 14:32 UTC (permalink / raw)
  To: gcc-bugs

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


lerdsuwa at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


------- Additional Comments From lerdsuwa at gcc dot gnu dot org  2003-08-27 14:32 -------
Not a bug.  You're confused between copy constructor
and default constructor.  The one in your code is a
copy constructor

  D::D(const D& d);

On the other hand, default constructor looks like

  D::D();


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
  2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor 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
  2003-08-27 16:01 ` bangerth at dealii dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: nicolas dot burrus at lrde dot epita dot fr @ 2003-08-27 15:38 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
  2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor gcc-bugzilla at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2003-08-27 15:38 ` nicolas dot burrus at lrde dot epita dot fr
@ 2003-08-27 16:01 ` bangerth at dealii dot org
  2003-08-28 14:49 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2003-08-27 16:01 UTC (permalink / raw)
  To: gcc-bugs

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


bangerth at dealii dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


------- Additional Comments From bangerth at dealii dot org  2003-08-27 16:01 -------
I think the request makes sense -- the bases are empty, so nothing can happen when 
you forget the base initializer. I've also opened the other PR again, which hasn't been 
fixed (or has reappeared) despite the message in the audit trail. 
 
W.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
  2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor gcc-bugzilla at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-08-28 14:49 UTC (permalink / raw)
  To: gcc-bugs

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


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
  2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor gcc-bugzilla at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: okohlbacher at gmx dot de @ 2004-02-18 10:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From okohlbacher at gmx dot de  2004-02-18 10:38 -------
This bug is present in 3.3.3 as well. It is a rather annoying bugger, as it appears as well as soon as you 
derive a class from std::fstream.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11804


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c++/11804] Wrong warning about explicit initialization of base class default constructor
  2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor gcc-bugzilla at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2004-02-18 10:38 ` okohlbacher at gmx dot de
@ 2004-04-27  2:53 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-27  2:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-27 01:55 -------
This is a dup of bug 11159.

*** This bug has been marked as a duplicate of 11159 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11804


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-04-27  1:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-05 10:11 [Bug c++/11804] New: Wrong warning about explicit initialization of base class default constructor 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
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

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).