https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92935
pskocik at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pskocik at gmail dot com --- Comment #1 from pskocik at gmail dot com --- I don't think typeof is supposed to lose qualifiers. _Generic(Expr,...) loses them for Expr in an rvalue conversion (also decays arrays to pointer), but __typeof is supposed to preserve everything--it does preserve qualifiers in other compilers (clang/tinycc) and in gcc: _Atomic const int aci=0; _Generic(&aci, _Atomic const int*: (void)0); //ok _Atomic typeof(const int) aci2=0; _Generic(&aci2, _Atomic const int*: (void)0); //ok but there does seem to be a bug in gcc in how typeof combines with pointer symbols (*) and other qualifiers where gcc appears to be curiously dropping all qualifiers if (and only if) one of the original qualifiers was _Atomic _Generic((typeof(aci)*)0, _Atomic const int*: (void)0); //gcc error (int*), ok on clang _Generic((typeof(aci2)*)0, _Atomic const int*: (void)0); //gcc error (int*), ok on clang _Generic((typeof(aci2) volatile*)0, _Atomic const volatile int*: (void)0); //gcc error (int volatile*), ok on clang Clang doesn't do this, and neither gcc or clang typeof drops any qualifiers if there's no _Atomic among them: //no qualifs dropped if no _Atomic was involved const int ci=0; _Generic(&ci, const int*: (void)0); //ok typeof(const int) ci2=0; _Generic(&ci2, const int*: (void)0); //ok _Generic((typeof(ci)*)0, const int*: (void)0); //ok _Generic((typeof(ci2)*)0, const int*: (void)0); //ok _Generic((typeof(ci2) volatile*)0, const volatile int*: (void)0); //ok https://gcc.godbolt.org/z/TwtEGP