The TYPE_MAIN_VARIANT() here was, for casts to a typedef'd type name, resulting in all information about the typedef's involvement getting lost. This drops necessary information for warnings and can make them confusing or even misleading. It also makes specialized warnings for unspecified-size system types (pid_t, uid_t, ...) impossible. gcc/c/ChangeLog: 2021-03-09 David Lamparter PR c/99526 * c-typeck.c (build_c_cast): retain (unqualified) typedefs in casts rather than stripping down to basic type. --- gcc/c/c-typeck.c | 39 ++++++++++++++++++++++++++--- gcc/testsuite/gcc.dg/cast-typedef.c | 35 ++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cast-typedef.c --- Hi GCC hackers, now that gcc 12 is open for development, I'd like to submit this patch for reconsideration. I've already gone through a bit of feedback while the gcc 11 release was happening, cf. here: https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566513.html I've repeated my testing (full bootstrap & make check on x86_64) and found nothing changed. Cheers, -David