From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0EA07385803B; Wed, 10 Mar 2021 18:57:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0EA07385803B From: "equinox-gccbugs at diac24 dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/99526] New: Casts should retain typedef information Date: Wed, 10 Mar 2021 18:57:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: equinox-gccbugs at diac24 dot net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Mar 2021 18:57:22 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99526 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 whe= ther 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) =3D> int; typeof((cint)v) =3D> int; typeof((ci)v) =3D> int; typeof((const i)v) =3D> int; The IMHO ideal situation would be: typedef int i; typedef const int cint; typedef const i ci; char v; typeof((i)v) =3D> i; typeof((cint)v) =3D> int; typeof((ci)v) =3D> i; typeof((const i)v) =3D> 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 fo= rmat 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.=