struct R1 {}; struct R2 : R1 {}; struct R3 : R1 {}; struct R4 : R2, R3 {}; struct A { virtual R1& foo(); }; struct B : virtual A { R2& foo(); }; struct C : virtual A { R3& foo(); }; struct D : B, C { R4& foo(); }; // should be rejected
R4 contains two subobjects of type R1. When D::foo is invoked in the context of A (e.g.: in the following function bar) the cast from R4 to R1 is ambiguous. Therefore D::foo should be rejected. void bar(D& d) { A& a = d; R1& res = a.foo(); } -- Summary: function with ambiguous covariant return-type is not rejected Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: peter dot pirkelbauer at tamu dot edu GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33821