public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107405] New: enums can be long in gcc-13
@ 2022-10-26  4:26 jirislaby at gmail dot com
  2022-10-26  4:28 ` [Bug c/107405] enums can be wrongly long in gcc-13 (in gnu99) jirislaby at gmail dot com
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: jirislaby at gmail dot com @ 2022-10-26  4:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107405
           Summary: enums can be long in gcc-13
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jirislaby at gmail dot com
  Target Milestone: ---

While compiling the kernel (next/master -- 89bf6e28373beef9) with gcc-13, I
see:
drivers/block/mtip32xx/mtip32xx.c:722:25: error: format '%x' expects argument
of type 'unsigned int', but argument 3 has type 'long in' [-Werror=format=]

That is:
enum {
Many members, see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/ata.h?id=4dc12f37a8e98e1dca5521c14625c869537b50b6#n25
};
...
#define PORT_IRQ_HANDLED \      
        (PORT_IRQ_SDB_FIS | PORT_IRQ_LEGACY | \
         PORT_IRQ_TF_ERR | PORT_IRQ_IF_ERR | \
         PORT_IRQ_CONNECT | PORT_IRQ_PHYRDY)


...
u32 port_stat;
...
        dev_warn(&dd->pdev->dev,
              "Port stat errors %x unhandled\n",
              (port_stat & ~PORT_IRQ_HANDLED));

So port_stat is uint, ~PORT_IRQ_HANDLED is derived from enum, which should be
int from standard.

Reduced testcase:
#include <stdio.h>
enum { A = 0xffffffff, B = 1 << 31, };
int main() { printf("%lx %x %zu\n", A, B, sizeof(B)); }

$ gcc-13 -std=gnu99 x.c -Wall -O2 && ./a.out
x.c: In function ‘main’:
x.c:3:27: warning: format ‘%x’ expects argument of type ‘unsigned int’, but
argument 3 has type ‘long int’ [-Wformat=]
    3 | int main() { printf("%lx %x %zu\n", A, B, sizeof(B)); }
      |                          ~^            ~
      |                           |            |
      |                           unsigned int long int
      |                          %lx
ffffffff 80000000 8
$ gcc-12 -std=gnu11 x.c -Wall -O2 && ./a.out
ffffffff 80000000 4

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

end of thread, other threads:[~2023-03-24  9:27 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  4:26 [Bug c/107405] New: enums can be long in gcc-13 jirislaby at gmail dot com
2022-10-26  4:28 ` [Bug c/107405] enums can be wrongly long in gcc-13 (in gnu99) jirislaby at gmail dot com
2022-10-26  6:55 ` marxin at gcc dot gnu.org
2022-10-26  7:08 ` marxin at gcc dot gnu.org
2022-10-26  7:27 ` jirislaby at gmail dot com
2022-10-26  7:31 ` jirislaby at gmail dot com
2022-10-26  7:45 ` jakub at gcc dot gnu.org
2022-10-26  7:53 ` jirislaby at gmail dot com
2022-10-26  8:04 ` jakub at gcc dot gnu.org
2022-10-26  8:21 ` redi at gcc dot gnu.org
2022-10-26  8:39 ` jirislaby at gmail dot com
2022-10-26  8:49 ` jirislaby at gmail dot com
2022-10-26 16:55 ` [Bug c/107405] [13 Regression] enum change causing Linux kernel to fail to build due to Linux depending on old behavior pinskia at gcc dot gnu.org
2022-10-26 17:35 ` joseph at codesourcery dot com
2022-10-28 11:19 ` rguenth at gcc dot gnu.org
2022-11-19  8:43 ` jakub at gcc dot gnu.org
2022-11-19 13:18 ` macro at orcam dot me.uk
2022-11-19 20:46 ` jakub at gcc dot gnu.org
2022-11-21 18:10 ` joseph at codesourcery dot com
2022-11-22 14:53 ` macro at orcam dot me.uk
2022-11-22 22:47 ` joseph at codesourcery dot com
2022-11-29 14:57 ` pinskia at gcc dot gnu.org
2023-01-13 11:36 ` rguenth at gcc dot gnu.org
2023-03-24  9:27 ` rguenth 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).