Dear support,
this topic was initially discussed at https://github.com/open-mpi/ompi/pull/2032#issuecomment-244311963 (for reference only)
oracle compilers (i tested the latest 12.5 on Linux) do issue some warning when builtin atomics are used, and they look like spurious warnings to me
let's try this sample program
#include <stdbool.h>
static inline int atomic( volatile int *addr, int oldval, int newval) {
return __atomic_compare_exchange_n (addr, &oldval, newval, false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED);
}
gcc
is perfectly happy with that, even with the -Wall
option
but cc
is not
$ /opt/oracle/developerstudio12.5/bin/cc -c atomic.c "atomic.c", line 5: warning: argument #2 is incompatible with prototype:
prototype: pointer to void : "atomic.c",
line 0 argument : pointer to volatile int
if i modify this program like this
#include <stdbool.h>
static inline int atomic( volatile int *addr, int oldval, int newval) {
return __atomic_compare_exchange_n (addr, (void *)&oldval, newval, false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED);
}
gcc -Wall
is still very happy, but thing got worst from cc
point of view
$ /opt/oracle/developerstudio12.5/bin/cc -c atomic.c "atomic.c", line 6: argument #2 of "__atomic_compare_exchange_n" should be non-void pointer type "atomic.c",
line 5: warning: argument #2 is incompatible with prototype:
prototype: pointer to void : "atomic.c",
line 0 argument : pointer to volatile int
if i read correctly
1. the second argument should not be a void *
2. the second argument is a volatile int *
but a void *
is expected !!!
to me, that looks like a spurious warning, could you please comment on that ?
Thanks and regards,
Gilles