Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look
OK for trunk/13/12?

-- >8 --

The get_target_expr call added in r12-7069-g119cea98f66476 causes us
for the below testcase to call build_vec_delete in a template context,
which builds a templated destructor call and checks expr_noexcept_p for
it, which ICEs because the call has templated form.  Much of the work
of build_vec_delete however is code generation and thus will just get
throw away in a template context, including this expr_noexcept_p check
and the code generation guarded by it.  So this patch narrowly fixes this
ICE by assuming the expr_noexcept_p call returns true in a template
context.

        PR c++/109899

gcc/cp/ChangeLog:

        * init.cc (build_vec_delete_1): Assume expr_noexcept_p is true
        in a template context.

gcc/testsuite/ChangeLog:

        * g++.dg/cpp0x/initlist-array21.C: New test.
---
 gcc/cp/init.cc                                |  3 ++-
 gcc/testsuite/g++.dg/cpp0x/initlist-array21.C | 12 ++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-array21.C

diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index 09584719ee6..aa0a35a3885 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -4155,7 +4155,8 @@ build_vec_delete_1 (location_t loc, tree base, tree 
maxindex, tree type,
 
   /* If one destructor throws, keep trying to clean up the rest, unless we're
      already in a build_vec_init cleanup.  */
-  if (flag_exceptions && !in_cleanup && !expr_noexcept_p (tmp, tf_none))
+  if (flag_exceptions && !in_cleanup && !processing_template_decl
+      && !expr_noexcept_p (tmp, tf_none))
     {
       loop = build2 (TRY_CATCH_EXPR, void_type_node, loop,
                     unshare_expr (loop));
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array21.C 
b/gcc/testsuite/g++.dg/cpp0x/initlist-array21.C
new file mode 100644
index 00000000000..5e37e3de62a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array21.C
@@ -0,0 +1,12 @@
+// PR c++/109899
+// { dg-do compile { target c++11 } }
+
+struct A { A(); ~A(); };
+
+template <typename T>
+using array = T[42];
+
+template<class T>
+void f() {
+  array<A>{};
+}
-- 
2.43.0.254.ga26002b628

Reply via email to