public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "equinox-gccbugs at diac24 dot net" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-99526-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
reply other threads:[~2021-03-10 18:57 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99526-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).