From 60634d0438f9c0c27204ae6656641a61aced7e59 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 25 Jul 2024 06:39:48 +0300 Subject: [PATCH] Workaround 'GC_cptr_compare_and_swap is never used' cppcheck FP (fix of commit 1fcf50d69) Issue #627 (bdwgc). * tests/atomicops.c [AO_HAVE_compare_and_swap_release] (main): Define cptr local variable; call GC_cptr_compare_and_swap() and check its result. --- tests/atomicops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/atomicops.c b/tests/atomicops.c index 4111619ea..a9db3ef0c 100644 --- a/tests/atomicops.c +++ b/tests/atomicops.c @@ -75,6 +75,12 @@ TA_assert(x == 13); TA_assert(AO_compare_and_swap_release(&x, 13, 42)); TA_assert(x == 42); + { + char *cptr = (char *)NULL; + + TA_assert(GC_cptr_compare_and_swap(&cptr, (char *)NULL, (char *)&x)); + TA_assert(cptr == (char *)&x); + } # else if (*(volatile AO_t *)&x == 13) *(volatile AO_t *)&x = 42;