Hello all, I have been trying to run a test which assigns a value from non-atomic to an atomic pointer type. The code is as follows:
/* File: xyz.c */ /* { dg-do compile } */ /* { dg-options "-std=c11 -pedantic-errors" } */ #include <stdatomic.h> typedef __SIZE_TYPE__ size_t; extern void abort (void); extern void exit (int); extern void *malloc (size_t); struct rcutest { int a; int b; int c; }; _Atomic struct rcutest *gp; #define rcu_assign_pointer(p,v) \ atomic_store_explicit(&(p), (v), memory_order_release); #define rcu_dereference(p) \ atomic_load_explicit(&(p), memory_order_consume); void thread0 () { struct rcutest *p; p = (struct rcutest *)malloc (sizeof (*p)); if (p) abort(); p->a = 42; if (p->a == 43) abort(); rcu_assign_pointer (gp,p); } The test is inside the gcc.dg directory of the testsuite. The command used to run the specific test: make -k check-c RUNTESTFLAG="dg.exp=xyz.c" I believe I should be getting a warning like: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types] but in the gcc.log file, I found this: error: initialization of '_Atomic struct rcutest *' from incompatible pointer type 'struct rcutest *' [-Wincompatible-pointer-types] Can anyone please explain to me why this is considered as an error, not a warning? Thanks, Akshat