restrict, _Atomic, and multidimensional arraysAuthors: Jay Ghiron
Date: 2026-06-12
Submitted against: C23
Status: Open
Types other than pointer types whose referenced type is an object type and (possibly multi-dimensional) array types with such pointer types as element type shall not be restrict-qualified.
(C23 6.7.4.1 "General" paragraph 2.)
This text does not clearly define whether the following is valid:
int*restrict _Atomic p;
GCC and MSVC accept it, Clang rejects it. I assume the intent is to allow it. See also LLVM issue 24825, LLVM issue 37206, and LLVM issue 173106. Additionally, it does not seem to allow:
int*restrict q[1][1];
The type int*restrict[1][1] is an array type, but its element type
is not a pointer type. Note that the wording "possibly
multi-dimensional" in parentheses is not modifying the meaning of
element type.
The following suggested correction assumes that "pointer type" does not include atomic types. Another solution would be to clearly define "pointer type" as including atomic types, and changing other type categories in the same way.
Replace C23 6.7.4.1 paragraph 2:
Types other than:
- atomic, qualified, or unqualified pointer types whose referenced types are object types,
- and array types whose element types satisfy the previous bullet or this bullet, recursively
shall not be restrict-qualified.(new footnote)
(new footnote) This constraint can also be violated by a conditional operator (6.5.16) if it attempts to form the type restrict-qualified
void.