]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: problematic assert in reference_binding [PR113141]
authorPatrick Palka <ppalka@redhat.com>
Wed, 1 May 2024 22:16:08 +0000 (18:16 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 1 May 2024 22:16:08 +0000 (18:16 -0400)
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.

gcc/cp/call.cc
gcc/testsuite/g++.dg/conversion/ref12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/initlist-ref1.C [new file with mode: 0644]

index b10bdc62d38135dd98c28e5b79e40a6da75a4be7..70c7f6178b88af8d701d899540e7484a89083eb6 100644 (file)
@@ -2017,7 +2017,6 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags,
            if (!new_second)
              return NULL;
            conv = merge_conversion_sequences (t, new_second);
-           gcc_assert (maybe_valid_p || conv->bad_p);
            return conv;
          }
     }
diff --git a/gcc/testsuite/g++.dg/conversion/ref12.C b/gcc/testsuite/g++.dg/conversion/ref12.C
new file mode 100644 (file)
index 0000000..633b7e4
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/113141
+
+struct Matrix { };
+
+struct TPoint3 { operator const Matrix(); };
+
+void f(Matrix&);
+
+int main() {
+  TPoint3 X;
+  Matrix& m = (Matrix &)X;
+  f((Matrix &)X);
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-ref1.C b/gcc/testsuite/g++.dg/cpp0x/initlist-ref1.C
new file mode 100644 (file)
index 0000000..f893f12
--- /dev/null
@@ -0,0 +1,16 @@
+// 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}});
+}