https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107756
Bug ID: 107756 Summary: Change in sizeof(enum) with -std=gnu11 breaks Linux kernel code compilation (PR c/36113 change regression) Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: macro at orcam dot me.uk CC: jsm28 at gcc dot gnu.org Target Milestone: --- Target: mips-linux-gnu Created attachment 53929 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53929&action=edit Preprocessor output from libahci.c; use lzip to decompress The fix for PR c/36113 has added support for C2x enums wider than int, but it seems to affect code built for earlier standards, such as with `-std=gnu11' and libahci.c code from Linux kernel, which causes an assertion failure with the `mips-linux-gnu' (o32) target as from commit 3b3083a598ca ("c: C2x enums wider than int [PR36113]"): In file included from <command-line>: drivers/ata/libahci.c: In function 'ahci_led_store': ././include/linux/compiler_types.h:357:45: error: call to '__compiletime_assert_309' declared with attribute error: BUILD_BUG_ON failed: sizeof(_s) > sizeof(long) 357 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^ ././include/linux/compiler_types.h:338:25: note: in definition of macro '__compiletime_assert' 338 | prefix ## suffix(); \ | ^~~~~~ ././include/linux/compiler_types.h:357:9: note: in expansion of macro '_compiletime_assert' 357 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^~~~~~~~~~~~~~~~~~~ ./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' 39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) | ^~~~~~~~~~~~~~~~~~ ./include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG' 50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) | ^~~~~~~~~~~~~~~~ ./include/linux/nospec.h:58:9: note: in expansion of macro 'BUILD_BUG_ON' 58 | BUILD_BUG_ON(sizeof(_s) > sizeof(long)); \ | ^~~~~~~~~~~~ drivers/ata/libahci.c:1198:23: note: in expansion of macro 'array_index_nospec' 1198 | pmp = array_index_nospec(pmp, EM_MAX_SLOTS); | ^~~~~~~~~~~~~~~~~~ with the compiler invocation as follows: mips-linux-gnu-gcc -Wp,-MMD,drivers/ata/.libahci.o.d -nostdinc -I./arch/mips/include -I./arch/mips/include/generated -I./include -I./arch/mips/include/uapi -I./arch/mips/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./include/linux/compiler_types.h -D__KERNEL__ -DVMLINUX_LOAD_ADDRESS=0xffffffff80100000 -DLINKER_LOAD_ADDRESS=0x80100000 -DDATAOFFSET=0 -fmacro-prefix-map=./= -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu11 -mno-check-zero-division -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float -ffreestanding -EB -fno-stack-check -Wa,-mno-fix-loongson3-llsc -march=mips32r2 -Wa,--trap -DTOOLCHAIN_SUPPORTS_VIRT -DTOOLCHAIN_SUPPORTS_XPA -DTOOLCHAIN_SUPPORTS_CRC -DTOOLCHAIN_SUPPORTS_DSP -DTOOLCHAIN_SUPPORTS_GINV -I./arch/mips/include/asm/mach-malta -I./arch/mips/include/asm/mach-generic -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fno-stack-protector -Wno-main -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-dangling-pointer -fomit-frame-pointer -fno-stack-clash-protection -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wcast-function-type -Wno-stringop-truncation -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wno-packed-not-aligned -DKBUILD_MODFILE='"drivers/ata/libahci"' -DKBUILD_BASENAME='"libahci"' -DKBUILD_MODNAME='"libahci"' -D__KBUILD_MODNAME=kmod_libahci -c -o drivers/ata/libahci.o drivers/ata/libahci.c This code builds just fine with earlier GCC checkouts. I have attached preprocessor output from libahci.c.