[Bug c++/9807] [3.3 regression] Derived class object used as default parameter for base class reference requires explicit cast to reference to base class
reichelt at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Tue Aug 5 14:55:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9807
reichelt at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|rejects-valid |diagnostic
Summary|Derived class object used as|[3.3 regression] Derived
|default parameter for base |class object used as default
|class reference requires |parameter for base class
|explicit cast to reference |reference requires explicit
|to base class |cast to reference to base
| |class
------- Additional Comments From reichelt at gcc dot gnu dot org 2003-08-05 14:55 -------
On mainline we now get
x.cc:9: error: invalid initialization of non-const reference of type 'A&'
from a temporary of type 'B'
x.cc:7: error: in passing argument 1 of `C::C(A&)'
for Wolfgang's small example. And I think that gcc is right here.
However, the error message on the 3.3 branch is still hosed:
x.cc:7: error: invalid type `B' for default argument to `A&'
x.cc:9: error: could not convert `B()' to `A&'
x.cc:7: error: in passing argument 1 of `C::C(A&)'
That's why I changed the keyword from "rejects-valid" to "diagnostic".
Since we already did better in 2.95.x (see below) I rate this as a
regression on the 3.3 branch
x.cc:7: invalid type `B' for default argument to `A &'
x.cc: In function `void __static_initialization_and_destruction_0(int, int)':
x.cc:9: initialization of non-const reference type `struct A &'
x.cc:9: from rvalue of type `B'
May others decide whether this will be fixed on the branch or not.
Btw, the error message got hosed with gcc 3.0.
More information about the Gcc-bugs
mailing list