public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112841] New: typeof_unqual is not removing qualifiers from array types
@ 2023-12-04  5:16 luigighiron at gmail dot com
  2023-12-04  6:43 ` [Bug c/112841] typeof_unqual is not removing qualifiers from the element type of " pinskia at gcc dot gnu.org
  2023-12-04  6:51 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: luigighiron at gmail dot com @ 2023-12-04  5:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112841

            Bug ID: 112841
           Summary: typeof_unqual is not removing qualifiers from array
                    types
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luigighiron at gmail dot com
  Target Milestone: ---

GCC does not remove qualifiers from array types when used with typeof_unqual:

puts(_Generic(
    (typeof_unqual(const int[])*)0,
    int(*)[]:"non-const",
    const int(*)[]:"const"
));

This should print non-const, but GCC prints const.

The latest working draft of the standard includes an example of typeof_unqual
with an array of const:

> EXAMPLE 2 The following program:
> const _Atomic int purr = 0;
> const int meow = 1;
> const char* const animals[] = {
> "aardvark",
> "bluejay",
> "catte",
> };
> typeof_unqual(meow) main (int argc, char* argv[]) {
> typeof_unqual(purr) plain_purr;
> typeof(_Atomic typeof(meow)) atomic_meow;
> typeof(animals) animals_array;
> typeof_unqual(animals) animals2_array;
> return 0;
> }
> is equivalent to this program:
> const _Atomic int purr = 0;
> const int meow = 1;
> const char* const animals[] = {
> "aardvark",
> "bluejay",
> "catte",
> };
> int main (int argc, char* argv[]) {
> int plain_purr;
> const _Atomic int atomic_meow;
> const char* const animals_array[3];
> const char* animals2_array[3];
> return 0;
> }
Section 6.7.2.5 "Typeof specifiers" Paragraph 7, from N3096

Here, GCC does not not remove the const on the array type for animals2_array in
the first part of the example.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-04  6:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-04  5:16 [Bug c/112841] New: typeof_unqual is not removing qualifiers from array types luigighiron at gmail dot com
2023-12-04  6:43 ` [Bug c/112841] typeof_unqual is not removing qualifiers from the element type of " pinskia at gcc dot gnu.org
2023-12-04  6:51 ` pinskia at gcc dot gnu.org

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