diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-09 03:58:00 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-05-09 03:58:00 +0000 |
commit | bcb3170cd7700c03e5017c0a2b4e845b5cb1d763 (patch) | |
tree | 09467b7a6778576ce54cf16a985769ff3c2dacb8 /libstdc++-v3/libsupc++ | |
parent | 7821c8c80c254f0dfd2a39f089d5bb1aa1bbed06 (diff) | |
download | gcc-bcb3170cd7700c03e5017c0a2b4e845b5cb1d763.tar.gz |
Core 624/N2932: Throw bad_array_new_length on overflow
in array new size calculation.
libstdc++-v3/
* libsupc++/new: Add std::bad_array_new_length.
* libsupc++/bad_array_new.cc: New.
* libsupc++/eh_aux_runtime.cc: Add __cxa_throw_bad_array_new_length.
* libsupc++/Makefile.in: Build them.
* config/abi/pre/gnu.ver: Add new symbols.
* config/abi/pre/gnu-versioned-namespace.ver: Add new symbols.
gcc/cp/
* init.c (throw_bad_array_new_length): New.
(build_new_1): Use it. Don't warn about braced-init-list.
(build_vec_init): Use it.
* call.c (build_operator_new_call): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198731 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/libsupc++')
-rw-r--r-- | libstdc++-v3/libsupc++/Makefile.in | 14 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/bad_array_new.cc | 36 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/cxxabi.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/eh_aux_runtime.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/libsupc++/new | 15 |
5 files changed, 71 insertions, 1 deletions
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in index eb13f1ea9ef..9f24fef30eb 100644 --- a/libstdc++-v3/libsupc++/Makefile.in +++ b/libstdc++-v3/libsupc++/Makefile.in @@ -92,7 +92,8 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(bitsdir)" \ LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES) libsupc___la_LIBADD = am__objects_1 = array_type_info.lo atexit_arm.lo atexit_thread.lo \ - bad_alloc.lo bad_cast.lo bad_typeid.lo class_type_info.lo \ + bad_alloc.lo bad_array_new.lo bad_cast.lo bad_typeid.lo \ + class_type_info.lo \ del_op.lo del_opnt.lo del_opv.lo del_opvnt.lo dyncast.lo \ eh_alloc.lo eh_arm.lo eh_aux_runtime.lo eh_call.lo eh_catch.lo \ eh_exception.lo eh_globals.lo eh_personality.lo eh_ptr.lo \ @@ -366,6 +367,7 @@ sources = \ atexit_arm.cc \ atexit_thread.cc \ bad_alloc.cc \ + bad_array_new.cc \ bad_cast.cc \ bad_typeid.cc \ class_type_info.cc \ @@ -788,6 +790,16 @@ cp-demangle.o: cp-demangle.c $(C_COMPILE) -DIN_GLIBCPP_V3 -Wno-error -c $< # Use special rules for the C++11 sources so that the proper flags are passed. +bad_array_new.lo: bad_array_new.cc + $(LTCXXCOMPILE) -std=gnu++11 -c $< +bad_array_new.o: bad_array_new.cc + $(CXXCOMPILE) -std=gnu++11 -c $< + +eh_aux_runtime.lo: eh_aux_runtime.cc + $(LTCXXCOMPILE) -std=gnu++11 -c $< +eh_aux_runtime.o: eh_aux_runtime.cc + $(CXXCOMPILE) -std=gnu++11 -c $< + eh_ptr.lo: eh_ptr.cc $(LTCXXCOMPILE) -std=gnu++11 -c $< eh_ptr.o: eh_ptr.cc diff --git a/libstdc++-v3/libsupc++/bad_array_new.cc b/libstdc++-v3/libsupc++/bad_array_new.cc new file mode 100644 index 00000000000..5282f525abf --- /dev/null +++ b/libstdc++-v3/libsupc++/bad_array_new.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of GCC. +// +// GCC is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 3, or (at your option) +// any later version. + +// GCC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// <http://www.gnu.org/licenses/>. + +#include <new> + +namespace std { + +bad_array_new_length::~bad_array_new_length() _GLIBCXX_USE_NOEXCEPT { } + +const char* +bad_array_new_length::what() const _GLIBCXX_USE_NOEXCEPT +{ + return "std::bad_array_new_length"; +} + +} // namespace std diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h index f5301c05d15..83749ce8038 100644 --- a/libstdc++-v3/libsupc++/cxxabi.h +++ b/libstdc++-v3/libsupc++/cxxabi.h @@ -151,6 +151,9 @@ namespace __cxxabiv1 void __cxa_bad_typeid() __attribute__((__noreturn__)); + void + __cxa_throw_bad_array_new_length() __attribute__((__noreturn__)); + /** * @brief Demangling routine. diff --git a/libstdc++-v3/libsupc++/eh_aux_runtime.cc b/libstdc++-v3/libsupc++/eh_aux_runtime.cc index 77980147145..1cc831b4b9f 100644 --- a/libstdc++-v3/libsupc++/eh_aux_runtime.cc +++ b/libstdc++-v3/libsupc++/eh_aux_runtime.cc @@ -24,6 +24,7 @@ #include "typeinfo" #include "exception" +#include "new" #include <cstdlib> #include "unwind-cxx.h" #include <bits/exception_defines.h> @@ -36,3 +37,6 @@ extern "C" void __cxxabiv1::__cxa_bad_typeid () { _GLIBCXX_THROW_OR_ABORT(std::bad_typeid()); } +extern "C" void +__cxxabiv1::__cxa_throw_bad_array_new_length () +{ _GLIBCXX_THROW_OR_ABORT(std::bad_array_new_length()); } diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index e3f0f7796f8..3087502190e 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -64,6 +64,21 @@ namespace std virtual const char* what() const throw(); }; +#if __cplusplus >= 201103L + class bad_array_new_length : public bad_alloc + { + public: + bad_array_new_length() throw() { }; + + // This declaration is not useless: + // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 + virtual ~bad_array_new_length() throw(); + + // See comment in eh_exception.cc. + virtual const char* what() const throw(); + }; +#endif + struct nothrow_t { }; extern const nothrow_t nothrow; |