From 3150107d3e12b06764e3fd4598cef0652e127b3c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Mon, 15 Jan 2018 08:20:02 +0300 Subject: [PATCH] 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. --- gc_cpp.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- 2.40.0