C++ PATCH for c++/86378, functional cast in template noexcept-specifier

Message ID CADzB+2nBAAdmzG4mWMYsfZyRP5=h5S90pzw=QfrywXv3W3epOQ@mail.gmail.com
State New
Headers show
Series
  • C++ PATCH for c++/86378, functional cast in template noexcept-specifier
Related show

Commit Message

Jason Merrill July 3, 2018, 4:24 p.m.
This was a simple typo in strip_typedefs_expr, where we were iterating
but then building a new list consisting entirely of the first element.

Tested x86_64-pc-linux-gnu, applying to trunk, 8, 7.

Patch

commit 1cab1ce37320aac67d8fbf88d10930f5c769cfb1
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Jul 2 15:09:58 2018 -0400

            PR c++/86378 - functional cast in noexcept-specifier.
    
            * tree.c (strip_typedefs_expr) [TREE_LIST]: Fix iteration.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 361248d4b52..b1333f55e39 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1735,9 +1735,9 @@  strip_typedefs_expr (tree t, bool *remove_attributes)
 	tree it;
 	for (it = t; it; it = TREE_CHAIN (it))
 	  {
-	    tree val = strip_typedefs_expr (TREE_VALUE (t), remove_attributes);
+	    tree val = strip_typedefs_expr (TREE_VALUE (it), remove_attributes);
 	    vec_safe_push (vec, val);
-	    if (val != TREE_VALUE (t))
+	    if (val != TREE_VALUE (it))
 	      changed = true;
 	    gcc_assert (TREE_PURPOSE (it) == NULL_TREE);
 	  }
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept33.C b/gcc/testsuite/g++.dg/cpp0x/noexcept33.C
new file mode 100644
index 00000000000..c5a03de38dd
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept33.C
@@ -0,0 +1,28 @@ 
+// PR c++/86378
+// { dg-do compile { target c++11 } }
+
+struct Pepper {};
+struct Apple { Apple(int) {} };
+
+struct Combination : Apple, Pepper
+{
+  Combination(Pepper p, Apple a)
+    : Apple(a), Pepper(p)
+  {}
+};
+
+struct MyCombination
+{
+  using Spice = Pepper;
+  using Fruit = Apple;
+
+  Combination combination;
+
+  template<typename T>
+  constexpr MyCombination(T&& t)
+  noexcept(noexcept(Combination(Spice(), Fruit(t))))
+    : combination(Spice(), Fruit(t))
+  {}
+};
+
+MyCombination obj(Apple(4));