From f391b44b199e27712c15ea880f54f41cd11f34e3 Mon Sep 17 00:00:00 2001 From: Alexander Ivchenko Date: Sat, 23 Nov 2013 16:28:42 +0000 Subject: [PATCH] re PR c++/58525 (__cxa_throw_bad_array_new_length is generated with -fno-exceptions) PR c++/58525 * call.c (build_operator_new_call): Add flag_exceptions check. * decl.c (compute_array_index_type): Ditto. * init.c (build_new_1): Ditto. (build_vec_init): Ditto. From-SVN: r205310 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/call.c | 2 +- gcc/cp/decl.c | 2 +- gcc/cp/init.c | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ee0674c2300..05aa444d439 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2013-11-23 Alexander Ivchenko + + PR c++/58525 + * call.c (build_operator_new_call): Add flag_exceptions check. + * decl.c (compute_array_index_type): Ditto. + * init.c (build_new_1): Ditto. + (build_vec_init): Ditto. + 2013-11-22 Jakub Jelinek * cp-gimplify.c: Include target.h and c-family/c-ubsan.h. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 935e0116771..6a4386eb5a4 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3956,7 +3956,7 @@ build_operator_new_call (tree fnname, vec **args, if (size_check != NULL_TREE) { tree errval = TYPE_MAX_VALUE (sizetype); - if (cxx_dialect >= cxx11) + if (cxx_dialect >= cxx11 && flag_exceptions) errval = throw_bad_array_new_length (); *size = fold_build3 (COND_EXPR, sizetype, size_check, original_size, errval); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 40a9a8cb7cc..889c203b1f1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8393,7 +8393,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) stabilize_vla_size (itype); - if (cxx_dialect >= cxx1y) + if (cxx_dialect >= cxx1y && flag_exceptions) { /* If the VLA bound is larger than half the address space, or less than zero, throw std::bad_array_length. */ diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d67a38969f6..dc40989cc10 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2528,7 +2528,7 @@ build_new_1 (vec **placement, tree type, tree nelts, } /* Perform the overflow check. */ tree errval = TYPE_MAX_VALUE (sizetype); - if (cxx_dialect >= cxx11) + if (cxx_dialect >= cxx11 && flag_exceptions) errval = throw_bad_array_new_length (); if (outer_nelts_check != NULL_TREE) size = fold_build3 (COND_EXPR, sizetype, outer_nelts_check, @@ -3398,7 +3398,8 @@ build_vec_init (tree base, tree maxindex, tree init, is big enough for all the initializers. */ if (init && TREE_CODE (init) == CONSTRUCTOR && CONSTRUCTOR_NELTS (init) > 0 - && !TREE_CONSTANT (maxindex)) + && !TREE_CONSTANT (maxindex) + && flag_exceptions) length_check = fold_build2 (LT_EXPR, boolean_type_node, maxindex, size_int (CONSTRUCTOR_NELTS (init) - 1));