From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22660 invoked by alias); 28 Oct 2010 09:17:46 -0000 Received: (qmail 22649 invoked by uid 22791); 28 Oct 2010 09:17:45 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,MISSING_MID X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Oct 2010 09:17:36 +0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/21917] Missing warning when trying to explicitly construct a virtual base X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 28 Oct 2010 09:17:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg02382.txt.bz2 Message-ID: <20101028091700.UgVA7rRvteNS6EomUlh6lrbkj2ZmJ9BV2VqO5Uav2yE@z> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917 --- Comment #8 from Jonathan Wakely 2010-10-28 09:17:23 UTC --- I've relied on exactly this behaviour and wouldn't want a warning. struct Base : virtual std::ios { Base() : std::ios(0) { } std::streambuf buf; }; struct MyStream : Base, std::iostream { MyStream() : std::iostream(0) { } }; If a concrete Base is constructed I want to call ios::ios(0) but if a MyStream is constructed then I want to call the ios::ios() default ctor and then have iostream::iostream(0) call ios::init(0) If this warning is added (which I'm not convinced it should be) then it should not be given if the most-derived class *explicitly* uses a different ctor for the virtual base i.e. I could suppress the warning by changing the code above like so: MyStream() : std::ios(), std::iostream(0) { } ^^^^^^^^^^^ I also don't think the warning should be given if the unused mem-initializer in der1 and der2 calls the same constructor as is implicitly called by the most-derived class, i.e. if der1 and der2 called virt() then that has the same effect as the implicit initialization done by top. I don't think this should be P2, and I think a better summary would be "Missing warning when virtual base is initialized with different constructor than requested by an ignored mem-initializer"