From c6a48c396c4093945ef0c2978f5ea63a4ef2042c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 26 Oct 2016 11:13:29 +0300 Subject: [PATCH] Eliminate 'suspicious pointer subtraction' cppcheck warning (gc_cpp) * include/gc_cpp.h (gc_cleanup::gc_cleanup): Define this_ptr void pointer; use this_ptr instead of this keyword to outline that the pointer subtraction is intentional (i.e., "this->" was not intended). --- include/gc_cpp.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/gc_cpp.h b/include/gc_cpp.h index b0ab2609..9110633f 100644 --- a/include/gc_cpp.h +++ b/include/gc_cpp.h @@ -428,11 +428,12 @@ inline gc_cleanup::gc_cleanup() { GC_finalization_proc oldProc; void* oldData; - void* base = GC_base((void*) this); + void* this_ptr = (void*)this; + void* base = GC_base(this_ptr); if (base != 0) { // Don't call the debug version, since this is a real base address. GC_register_finalizer_ignore_self(base, (GC_finalization_proc) cleanup, - (void*) ((char*) this - (char*) base), + (void*)((char*)this_ptr - (char*)base), &oldProc, &oldData); if (oldProc != 0) { GC_register_finalizer_ignore_self(base, oldProc, oldData, 0, 0); -- 2.40.0