https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117781
Bug ID: 117781 Summary: typeof_unqual should not remove atomic from an array of atomic type Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: luigighiron at gmail dot com Target Milestone: --- The patch to PR112841 introduced a new bug into typeof_unqual: typedef int x[2]; typedef typeof_unqual(_Atomic int[2])x; int main(){} GCC currently accepts this code, and Clang rejects it. This code should be invalid, and conversely if the first declaration was "typedef _Atomic int x[2];" then it should be valid. In C23 an array like const int[2] is considered to be const qualified, but an array like _Atomic int[2] is not considered to be atomic. So, typeof_unqual should remove const, volatile, and restrict from the element type of an array but not _Atomic. > An array and its element type are always considered to be identically > qualified. > > (footnote) This does not apply to the _Atomic qualifier. Note that qualifiers > do not have any direct effect on the array type itself, but affect conversion > rules for pointer types that reference an array type. Section 6.2.5 "Types" Paragraph 31 ISO/IEC 9899:2024