The standard states in 7.17.5.1 that atomic_is_lock_free has to be called with *a pointer to* the object in dispute.
So, except I am terribly mistaken, if the object is a pointer, one has to pass a pointer to a pointer.
But in the following test code one gets e. g.:
error #2141: Type error in argument 1 to 'atomic_is_lock_free'; '_Atomic float * *' is invalid.
Am I missing or misunderstanding something?
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
_Atomic float var_float;
_Atomic double var_double;
_Atomic long double var_long_double;
_Atomic float* p_var_float;
_Atomic double* p_var_double;
_Atomic long double* p_var_long_double;
atomic_init(&var_float, 42.0);
atomic_init(&var_double, 4711.1);
atomic_init(&var_long_double, 1000000.12);
atomic_init(&p_var_float, &var_float);
atomic_init(&p_var_double, &var_double);
atomic_init(&p_var_long_double, &var_long_double);
printf("\"_Atomic float var_float\" is %slock-free.\n", atomic_is_lock_free(& var_float) ? "" : "not ");
printf("\"_Atomic double var_double\" is %slock-free.\n", atomic_is_lock_free(& var_double) ? "" : "not ");
printf("\"_Atomic long double var_long_double\" is %slock-free.\n", atomic_is_lock_free(& var_long_double) ? "" : "not ");
printf("\"_Atomic float* p_var_float\" is %slock-free.\n", atomic_is_lock_free(&p_var_float) ? "" : "not ");
printf("\"_Atomic double* p_var_double\" is %slock-free.\n", atomic_is_lock_free(&p_var_double) ? "" : "not ");
printf("\"_Atomic long double* p_var_long_double\" is %slock-free.\n", atomic_is_lock_free(&p_var_long_double) ? "" : "not ");
exit(EXIT_SUCCESS);
}
Werner (on version 12.00)