r14-9946 / r14-9947 fixed this PR properly for GCC 14.
For GCC 13, let's just remove the problematic assert.
PR c++/113141
gcc/cp/ChangeLog:
* call.cc (reference_binding): Remove badness criteria sanity
check in the recursive case.
gcc/testsuite/ChangeLog:
* g++.dg/conversion/ref12.C: New test.
* g++.dg/cpp0x/initlist-ref1.C: new test.
if (!new_second)
return NULL;
conv = merge_conversion_sequences (t, new_second);
- gcc_assert (maybe_valid_p || conv->bad_p);
return conv;
}
}
--- /dev/null
+// PR c++/113141
+
+struct Matrix { };
+
+struct TPoint3 { operator const Matrix(); };
+
+void f(Matrix&);
+
+int main() {
+ TPoint3 X;
+ Matrix& m = (Matrix &)X;
+ f((Matrix &)X);
+}
--- /dev/null
+// PR c++/113141
+// { dg-do compile { target c++11 } }
+
+struct ConvToRef {
+ operator int&();
+};
+
+struct A { int& r; };
+
+void f(A);
+
+int main() {
+ ConvToRef c;
+ A a{{c}};
+ f({{c}});
+}