aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-04-05 00:01:15 -0400
committerJason Merrill <jason@gcc.gnu.org>2018-04-05 00:01:15 -0400
commitda0c8d9793df1083a21628efdb6368174d2d78d4 (patch)
tree02e5625e3cf47194502c624ba7dbcde985e579d3
parent67e1eb3d2dc87b13186fe00fcdd6361b8694f613 (diff)
downloadgcc-da0c8d9793df1083a21628efdb6368174d2d78d4.zip
gcc-da0c8d9793df1083a21628efdb6368174d2d78d4.tar.gz
gcc-da0c8d9793df1083a21628efdb6368174d2d78d4.tar.bz2
PR c++/85215 - ICE with copy-init from conversion.
* call.c (merge_conversion_sequences): Fix type of direct binding sequence. From-SVN: r259123
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/call.c6
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/elide3.C15
3 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 22f3e42..fd33f00 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2018-04-04 Jason Merrill <jason@redhat.com>
+ PR c++/85215 - ICE with copy-init from conversion.
+ * call.c (merge_conversion_sequences): Fix type of direct binding
+ sequence.
+
PR c++/84938 - ICE with division by ~-1.
* call.c (set_up_extended_ref_temp): Call cp_fully_fold.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 7c99e8a..f2ada27 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3642,6 +3642,12 @@ merge_conversion_sequences (conversion *user_seq, conversion *std_seq)
(*t)->bad_p = true;
}
+ if ((*t)->rvaluedness_matches_p)
+ /* We're binding a reference directly to the result of the conversion.
+ build_user_type_conversion_1 stripped the REFERENCE_TYPE from the return
+ type, but we want it back. */
+ user_seq->type = TREE_TYPE (TREE_TYPE (user_seq->cand->fn));
+
/* Replace the identity conversion with the user conversion
sequence. */
*t = user_seq;
diff --git a/gcc/testsuite/g++.dg/cpp1z/elide3.C b/gcc/testsuite/g++.dg/cpp1z/elide3.C
new file mode 100644
index 0000000..ca4d247
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/elide3.C
@@ -0,0 +1,15 @@
+// PR c++/85215
+// { dg-do compile { target c++11 } }
+
+template <typename _Tp> struct vector {
+ vector(vector &&) noexcept;
+};
+
+template <typename T> struct any_container {
+ operator vector<T> &&();
+};
+
+void f (any_container<int> c)
+{
+ vector<int> shape (c);
+}