Created
July 7, 2022 06:42
-
-
Save jarcode-foss/e8b16cb3d7261c9f14247db471a52603 to your computer and use it in GitHub Desktop.
Demonstrate valgrind false positive for "Conditional jump or move depends on uninitialised value(s)"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stdbool.h> | |
static int foo = 42; | |
#define _arch_load(addr, memorder) \ | |
({ \ | |
__auto_type _addr = addr; \ | |
typeof(*_addr) _store; \ | |
__atomic_compare_exchange(&_store, &_store, \ | |
_addr, false, memorder, memorder); \ | |
_store; \ | |
}) | |
int main(int argc, char** argv) { | |
int f = _arch_load(&foo, __ATOMIC_SEQ_CST); | |
printf("f = %d\n", f); | |
return EXIT_SUCCESS; | |
} | |
// gcc test_valgrind_cmpxchg.c -o test_valgrind_cmpxchg | |
// valgrind ./test_valgrind_cmpxchg | |
// $ valgrind --version | |
// valgrind-3.19.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment