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 * c-typeck.c (build_c_cast): retain (unqualified) typedefs in casts rather than stripping down to basic type. --- gcc/c/c-typeck.c | 11 +++++++---- gcc/testsuite/gcc.dg/cast-5.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/cast-5.c