Qualifiers not being discarded for atomic types while compiling with clang

Hi,
I am trying to compile the following:

char * _Atomic restrict h;

When compiled with -std=c11,clang gives error:

“restrict requires a pointer or reference (_Atomic(char*) is invalid)”

while gcc compiles it successfully.

Similarly, while trying to compile this

extern int i;
extern int _Atomic const ci;
extern __typeof(ci) i;

Clang gives error:

"Redeclaration of ‘i’ with a different type: ‘typeof (ci)’ (aka ‘typeof _Atomic(int)’) vs ‘int’ "

while gcc compiles it successfully.

This seems to be because clang probably considers Atomic int differently than int while gcc disregards these.

Please suggest what should be the right behaviour in such cases.

Thanks in advance.
Best regards,
Puneetha

This one is entirely legit. "_Atomic int" and "int" are very different
types, they may even have different alignment requirements.

Joerg

Hi,
I am trying to compile the following:

char * _Atomic restrict h;

When compiled with -std=c11,clang gives error:
         "restrict requires a pointer or reference (_Atomic(char*) is
invalid)"

C11 6.7.3/5: "If other qualifiers appear along with the _Atomic qualifier
in a specifier-qualifier-list, the resulting type is the so-qualified
atomic type."

So the type of 'h' is 'restrict _Atomic(char*)', not '_Atomic(char
*restrict)'.

C11 6.7.3/2: "Types other than pointer types whose referenced type is an
object type shall not be restrict-qualified."

The type being restrict-qualified is _Atomic(char*), which is an atomic
type, not a pointer type, and thus this is ill-formed. (As it happens,
'_Atomic(char *restrict)' would also be ill-formed, due to 6.7.2.4/3: "The
type name in an atomic type specifier shall not refer to [...] a qualified
type.")