This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11804] Wrong warning about explicit initialization of base class default constructor


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]