Skip to content

Commit

Permalink
Workaround 'GC_cptr_compare_and_swap is never used' cppcheck FP
Browse files Browse the repository at this point in the history
(fix of commit 1fcf50d)

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.
  • Loading branch information
ivmai committed Jul 25, 2024
1 parent 6fea3f1 commit 60634d0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/atomicops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 60634d0

Please sign in to comment.