https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112841
Bug ID: 112841 Summary: typeof_unqual is not removing qualifiers from array types Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: luigighiron at gmail dot com Target Milestone: --- GCC does not remove qualifiers from array types when used with typeof_unqual: puts(_Generic( (typeof_unqual(const int[])*)0, int(*)[]:"non-const", const int(*)[]:"const" )); This should print non-const, but GCC prints const. The latest working draft of the standard includes an example of typeof_unqual with an array of const: > EXAMPLE 2 The following program: > const _Atomic int purr = 0; > const int meow = 1; > const char* const animals[] = { > "aardvark", > "bluejay", > "catte", > }; > typeof_unqual(meow) main (int argc, char* argv[]) { > typeof_unqual(purr) plain_purr; > typeof(_Atomic typeof(meow)) atomic_meow; > typeof(animals) animals_array; > typeof_unqual(animals) animals2_array; > return 0; > } > is equivalent to this program: > const _Atomic int purr = 0; > const int meow = 1; > const char* const animals[] = { > "aardvark", > "bluejay", > "catte", > }; > int main (int argc, char* argv[]) { > int plain_purr; > const _Atomic int atomic_meow; > const char* const animals_array[3]; > const char* animals2_array[3]; > return 0; > } Section 6.7.2.5 "Typeof specifiers" Paragraph 7, from N3096 Here, GCC does not not remove the const on the array type for animals2_array in the first part of the example.