From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20207 invoked by alias); 5 Mar 2003 22:06:50 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 20187 invoked by uid 48); 5 Mar 2003 22:06:50 -0000 Date: Wed, 05 Mar 2003 22:06:00 -0000 Message-ID: <20030305220650.20186.qmail@sources.redhat.com> To: frank6thursday@aol.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org From: bangerth@dealii.org Reply-To: bangerth@dealii.org, frank6thursday@aol.com, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org Subject: Re: c++/9807: Derived class object used as default parameter for base class reference requires explicit cast to reference to base class X-SW-Source: 2003-03/txt/msg00231.txt.bz2 List-Id: Synopsis: Derived class object used as default parameter for base class reference requires explicit cast to reference to base class State-Changed-From-To: open->analyzed State-Changed-By: bangerth State-Changed-When: Wed Mar 5 22:06:50 2003 State-Changed-Why: Confirmed. I think the compiler should accept this, but no version of gcc does that. It works, though, if the reference parameter is constant. Here's a smaller code: ---------------------- struct A { virtual ~A(); }; struct B : A {}; struct C { C(A& a = B()){} }; C c; ------------------------ This is what I get: g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc x.cc:9: error: could not convert `B()' to `A&' x.cc:7: error: in passing argument 1 of `C::C(A&)' There's something more weird: If I remove the virtual destructor, then I get the following error message: g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc x.cc:9: error: could not convert `{}' to `A&' ^^^^ !!!! x.cc:7: error: in passing argument 1 of `C::C(A&)' That looks like real bogus! W. http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9807