From: Ivan Maidanski Date: Mon, 15 Jan 2018 05:20:02 +0000 (+0300) Subject: Fix global operator delete definition for C++14 in gc_cpp X-Git-Tag: v8.0.0~425 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3150107d3e12b06764e3fd4598cef0652e127b3c;p=gc Fix global operator delete definition for C++14 in gc_cpp Issue #195 (bdwgc). Sized variants of global operator delete should be defined along with the non-sized ones. Otherwise compiler might invoke the one from the standard library (as observed in e.g. Cygwin) leading to a crash. * gc_cpp.cc [!_MSC_VER && __cplusplus>201103L] (operator delete): Define sized variant (the size argument is ignored for now). * gc_cpp.cc [!_MSC_VER && __cplusplus>201103L && GC_OPERATOR_NEW_ARRAY && !CPPCHECK] (operator delete[]): Likewise. --- diff --git a/gc_cpp.cc b/gc_cpp.cc index 04737dce..80a9708a 100644 --- a/gc_cpp.cc +++ b/gc_cpp.cc @@ -62,4 +62,18 @@ built-in "new" and "delete". } # endif // GC_OPERATOR_NEW_ARRAY +# if __cplusplus > 201103L // C++14 + void operator delete(void* obj, size_t size) GC_DECL_DELETE_THROW { + (void)size; // size is ignored + GC_FREE(obj); + } + +# if defined(GC_OPERATOR_NEW_ARRAY) && !defined(CPPCHECK) + void operator delete[](void* obj, size_t size) GC_DECL_DELETE_THROW { + (void)size; + GC_FREE(obj); + } +# endif +# endif // C++14 + #endif // !_MSC_VER