Fix delete operator redirection if gc_cpp is built as .dll (Cygwin, MinGW)

Issue #229 (bdwgc).

* include/gc_cpp.h [(__CYGWIN32__ || __CYGWIN__ || __MINGW32__)
&& !GC_BUILD && !GC_NOT_DLL && GC_OPERATOR_NEW_ARRAY] (operator new[],
operator delete[]): Define inline function.
* include/gc_cpp.h [(__CYGWIN32__ || __CYGWIN__ || __MINGW32__)
&& !GC_BUILD && !GC_NOT_DLL] (operator new, operator delete): Likewise.
* include/gc_cpp.h [_MSC_VER || __DMC__ || (__CYGWIN32__ || __CYGWIN__
|| __MINGW32__) && !GC_BUILD && !GC_NOT_DLL && __cplusplus>201103L]
(operator delete(void*,size_t)): Likewise.
* include/gc_cpp.h [_MSC_VER || __DMC__ || (__CYGWIN32__ || __CYGWIN__
|| __MINGW32__) && !GC_BUILD && !GC_NOT_DLL && __cplusplus>201103L
&& GC_OPERATOR_NEW_ARRAY && !CPPCHECK]
(operator delete[](void*,size_t)): Likewise.
* include/gc_cpp.h (operator new(size_t, int, const char*, int),
operator new[](size_t, int, const char*, int)): Do not define
for __DMC__.
This commit is contained in:
Ivan Maidanski
2018-08-15 10:23:33 +03:00
parent da5233fb12
commit 5e51e8de5b
+20 -1
View File
@@ -306,7 +306,9 @@ inline void* operator new(size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
void*) GC_NOEXCEPT;
#endif
#if defined(_MSC_VER) || defined(__DMC__)
#if defined(_MSC_VER) || defined(__DMC__) \
|| ((defined(__CYGWIN32__) || defined(__CYGWIN__) \
|| defined(__MINGW32__)) && !defined(GC_BUILD) && !defined(GC_NOT_DLL))
// The following ensures that the system default operator new[] does not
// get undefined, which is what seems to happen on VC++ 6 for some reason
// if we define a multi-argument operator new[].
@@ -341,6 +343,23 @@ inline void* operator new(size_t size, GC_NS_QUALIFY(GCPlacement) gcp,
GC_FREE(obj);
}
# if __cplusplus > 201103L // C++14
inline void operator delete(void* obj, size_t size) GC_NOEXCEPT {
(void)size; // size is ignored
GC_FREE(obj);
}
# if defined(GC_OPERATOR_NEW_ARRAY) && !defined(CPPCHECK)
inline void operator delete[](void* obj, size_t size) GC_NOEXCEPT {
(void)size;
GC_FREE(obj);
}
# endif
# endif // C++14
#endif
#ifdef _MSC_VER
// This new operator is used by VC++ in case of Debug builds:
# ifdef GC_DEBUG
inline void* operator new(size_t size, int /* nBlockUse */,