Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

spurious warning with builtin atomics ?

3034537Sep 4 2016 — edited Sep 5 2016

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

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 2 2016
Added on Sep 4 2016
0 comments
445 views