public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99526] New: Casts should retain typedef information
@ 2021-03-10 18:57 equinox-gccbugs at diac24 dot net
  0 siblings, 0 replies; only message in thread
From: equinox-gccbugs at diac24 dot net @ 2021-03-10 18:57 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-10 18:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 18:57 [Bug c/99526] New: Casts should retain typedef information equinox-gccbugs at diac24 dot net

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).