*ping*
thanks, Alexander 2013/9/23 Alexander Ivchenko <aivch...@gmail.com>: > Hi, > > When I compile the following code (modified version of > g++.dg/cpp0x/bad_array_new1.C without try/catch): > > // { dg-options -std=c++11 } > // { dg-do run } > > #include <new> > > void * f(int i) > { > return new int[i]; > } > > int main() > { > f(-1); > } > > with -fno-exceptions option, I still get the call to > __cxa_throw_bad_array_new_length: > >> nm ./bad_array_new1.o | grep cxa > U __cxa_throw_bad_array_new_length > > > The same goes for __cxa_throw_bad_array_length. Is it an expected behaviour? > > May be I am missing something, but I would say that this is a bug and we > should > add something like the following checks: > > > diff --git a/gcc/cp/call.c b/gcc/cp/call.c > index 3ed73b8..c947484 100644 > --- a/gcc/cp/call.c > +++ b/gcc/cp/call.c > @@ -3953,7 +3953,7 @@ build_operator_new_call (tree fnname, vec<tree, > va_gc> **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 80ceca1..d058e94 100644 > --- a/gcc/cp/decl.c > +++ b/gcc/cp/decl.c > @@ -6390,7 +6390,9 @@ cp_finish_decl (tree decl, tree init, bool > init_const_expr_p, > && TYPE_FOR_JAVA (type) && MAYBE_CLASS_TYPE_P (type)) > error ("non-static data member %qD has Java class type", decl); > > - if (cxx_dialect >= cxx1y && array_of_runtime_bound_p (type)) > + if (cxx_dialect >= cxx1y > + && array_of_runtime_bound_p (type) > + && 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 8fabdcd..53046ab 100644 > --- a/gcc/cp/init.c > +++ b/gcc/cp/init.c > @@ -2488,7 +2488,7 @@ build_new_1 (vec<tree, va_gc> **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, > @@ -3345,7 +3345,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)); > > > thanks, > Alexander