]> granicus.if.org Git - gc/commitdiff
Fix 'ISO C++17 does not allow dynamic exception spec' clang-8 error
authorIvan R <iarspider@gmail.com>
Fri, 14 Jun 2019 09:24:47 +0000 (11:24 +0200)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 21 Jun 2019 21:33:17 +0000 (00:33 +0300)
Issue #287 (bdwgc).

Before this patch, clang 8 (and -std=c++1z) fails for gc_cpp.cc.
The error message produced is: ISO C++17 does not allow dynamic
exception specifications.

The "dynamic exception" syntax was declared deprecated in C++11 and
removed in C++17.

* gc_cpp.cc [!_MSC_VER && !__DMC__ && GC_NEW_DELETE_NEED_THROW
&& __cplusplus >= 201703L] (GC_DECL_NEW_THROW): Define to
noexcept(false); add comment.

gc_cpp.cc

index baf8ca4986780a66ff70e7e285d84176d87910a2..16c1035ff6d76c381d27ac31a4914012bd0c14a3 100644 (file)
--- a/gc_cpp.cc
+++ b/gc_cpp.cc
@@ -53,7 +53,13 @@ GC_API void GC_CALL GC_throw_bad_alloc() {
 # endif
 
 # ifdef GC_NEW_DELETE_NEED_THROW
-#   define GC_DECL_NEW_THROW throw(std::bad_alloc)
+#   if __cplusplus < 201703L
+#     define GC_DECL_NEW_THROW throw(std::bad_alloc)
+#   else
+      // The "dynamic exception" syntax was deprecated in C++11
+      // and removed in C++17.
+#     define GC_DECL_NEW_THROW noexcept(false)
+#   endif
 # else
 #   define GC_DECL_NEW_THROW /* empty */
 # endif