public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107917] New: [13 regression?] Size of enum type doesn't match size of enum value
@ 2022-11-29 14:43 luis.machado at arm dot com
  2022-11-29 14:56 ` [Bug c/107917] [13 regression?][arm] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: luis.machado at arm dot com @ 2022-11-29 14:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107917
           Summary: [13 regression?] Size of enum type doesn't match size
                    of enum value
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luis.machado at arm dot com
  Target Milestone: ---

I noticed this with both arm-none-eabi-gcc and arm-none-linux-gnueabihf-gcc,
version 13 ((20d2a8c24f3ca487ffd35fefcc9b1562bb10b609).

While attempting to build the Linux Kernel for 32-bit arm, I kept running into
the following assertion:

linux/drivers/ata/libahci.c: In function 'ahci_led_store':
linux/include/linux/compiler_types.h:357:45: error: call to
'__compiletime_assert_302' declared with attribute error: BUILD_BUG_ON failed:
sizeof(_s) > sizeof(long)
  357 |         _compiletime_assert(condition, msg, __compiletime_assert_,
__COUNTER__)


The context is we're passing a enum value (_s) that is part of an enum type
also defining (1 << 31). Supposedly the presence of a enum value (1 << 31)
makes gcc bump the size of the enum type to 64-bit.

This can be reproduced with the following:

enum {
      A = 1 <<31,
      B = 0xffffffff,
} e;

int s1 = sizeof(A);
int s2 = sizeof(B);
int s3 = sizeof(e);

Check the output on godbolt: https://godbolt.org/z/YaK3E8jEc

For gcc 13:

s3:
        .word   8
s2:
        .word   8
s1:
        .word   8
e:

For gcc 12.2:

e:
s1:
        .word   4
s2:
        .word   8
s3:
        .word   8


It is not completely clear if this change in behavior was intended or not. It
certainly diverges from what gcc did before and what clang does currently.

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

* [Bug c/107917] [13 regression?][arm] Size of enum type doesn't match size of enum value
  2022-11-29 14:43 [Bug c/107917] New: [13 regression?] Size of enum type doesn't match size of enum value luis.machado at arm dot com
@ 2022-11-29 14:56 ` pinskia at gcc dot gnu.org
  2022-11-29 14:57 ` pinskia at gcc dot gnu.org
  2022-11-29 15:02 ` luis.machado at arm dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-29 14:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
C23 fix ....

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

* [Bug c/107917] [13 regression?][arm] Size of enum type doesn't match size of enum value
  2022-11-29 14:43 [Bug c/107917] New: [13 regression?] Size of enum type doesn't match size of enum value luis.machado at arm dot com
  2022-11-29 14:56 ` [Bug c/107917] [13 regression?][arm] " pinskia at gcc dot gnu.org
@ 2022-11-29 14:57 ` pinskia at gcc dot gnu.org
  2022-11-29 15:02 ` luis.machado at arm dot com
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-29 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 107405.

*** This bug has been marked as a duplicate of bug 107405 ***

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

* [Bug c/107917] [13 regression?][arm] Size of enum type doesn't match size of enum value
  2022-11-29 14:43 [Bug c/107917] New: [13 regression?] Size of enum type doesn't match size of enum value luis.machado at arm dot com
  2022-11-29 14:56 ` [Bug c/107917] [13 regression?][arm] " pinskia at gcc dot gnu.org
  2022-11-29 14:57 ` pinskia at gcc dot gnu.org
@ 2022-11-29 15:02 ` luis.machado at arm dot com
  2 siblings, 0 replies; 4+ messages in thread
From: luis.machado at arm dot com @ 2022-11-29 15:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Luis Machado <luis.machado at arm dot com> ---
Thanks for linking it Andrew.

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

end of thread, other threads:[~2022-11-29 15:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 14:43 [Bug c/107917] New: [13 regression?] Size of enum type doesn't match size of enum value luis.machado at arm dot com
2022-11-29 14:56 ` [Bug c/107917] [13 regression?][arm] " pinskia at gcc dot gnu.org
2022-11-29 14:57 ` pinskia at gcc dot gnu.org
2022-11-29 15:02 ` luis.machado at arm dot com

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