summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-04-14 09:27:05 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-28 20:10:55 +0300
commit74f06fe0606c300b9e61267f77118ea6817b520d (patch)
tree90a6c399b898fc2ad7cea96e6912ffd1770aee91
parent308ae952064b11a688af3945b4d6b2e41524e27b (diff)
downloadbdwgc-74f06fe0606c300b9e61267f77118ea6817b520d.tar.gz
Ensure 'new' system header is included by gc_cpp.h if GC_INCLUDE_NEW
(a cherry-pick of commit d1bc109ec from 'master') * include/gc_cpp.h [GC_INCLUDE_NEW]: Include <new> right after include gc.h (regardless of GC_NEW_ABORTS_ON_OOM and _LIBCPP_NO_EXCEPTIONS).
-rw-r--r--include/gc_cpp.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/gc_cpp.h b/include/gc_cpp.h
index f3e8948a..85c1eb7d 100644
--- a/include/gc_cpp.h
+++ b/include/gc_cpp.h
@@ -142,6 +142,10 @@ by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined.
#include "gc.h"
+#ifdef GC_INCLUDE_NEW
+# include <new> // for std, bad_alloc
+#endif
+
#ifdef GC_NAMESPACE
# define GC_NS_QUALIFY(T) boehmgc::T
#else
@@ -193,7 +197,6 @@ by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined.
# define GC_OP_NEW_OOM_CHECK(obj) \
do { if (!(obj)) GC_abort_on_oom(); } while (0)
#elif defined(GC_INCLUDE_NEW)
-# include <new> // for bad_alloc
# define GC_OP_NEW_OOM_CHECK(obj) if (obj) {} else throw std::bad_alloc()
#else
// "new" header is not included, so bad_alloc cannot be thrown directly.