https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99526
Bug ID: 99526 Summary: Casts should retain typedef information Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: equinox-gccbugs at diac24 dot net Target Milestone: --- Currently, any cast in C will produce the "resolved" type regardless of whether the cast is written using a typedef. E.g.: typedef int i; typedef const int cint; typedef const i ci; char v; typeof((i)v) => int; typeof((cint)v) => int; typeof((ci)v) => int; typeof((const i)v) => int; The IMHO ideal situation would be: typedef int i; typedef const int cint; typedef const i ci; char v; typeof((i)v) => i; typeof((cint)v) => int; typeof((ci)v) => i; typeof((const i)v) => i; Note that since casts produce rvalues, qualifiers need to be stripped, and thus "ci" and "cint" shouldn't be used since the typedef itself contains a qualifier. My rationale for this is twofold: - systems (on POSIX: pid_t, uid_t, gid_t, ...) have some types that are of "unspecified" size, and it is helpful to be able to warn when these are intermixed. Especially in printf() due to varargs calling: there is no format specifier that is correct for these types. - plugins may want to attach additional semantics to some typedefs, and this breaks if the plugin can't get at the typedef.