For this much reduced C source code: struct { struct { int Reserved : 32 } }; struct { struct { int Reserved } }; seems to go wrong with recent gcc trunk: cvise $ ~/gcc/results/bin/gcc -c -w -g bug1069.c bug1069.c:10:1: error: ‘TYPE_CANONICAL’ is not compatible 10 | }; | ^ <record_type 0x7f4dd55de150 asm_written SI size <integer_cst 0x7f4dd5424198 type <integer_type 0x7f4dd54220a8 bitsizetype> constant 32> ... It's ok without the -g debug flag: cvise $ ~/gcc/results/bin/gcc -c -w bug1069.c cvise $ The bug first seems to occur sometime between g:fff5cfa4353e0c45 and g:6350e956d1a74963, which is 52 commits.
Fixed up testcase: struct { struct { int Reserved : 32; } u; } v; struct { struct { int Reserved; } u; } w; Started with r15-5470-g8b02cc9a4f2b8db48da
note -g only triggers type verfication
A check is needed in tagged_tu_types_compatible_p. In C23 the following needs to be rejected: struct foo { struct { int Reserved : 32; } }; struct foo { struct { int Reserved; } };
PATCH: https://gcc.gnu.org/pipermail/gcc-patches/2024-November/670331.html
The master branch has been updated by Martin Uecker <uecker@gcc.gnu.org>: https://gcc.gnu.org/g:b6a513909793a87b62ca52da85ff3baa44f6b4b6 commit r15-5792-gb6a513909793a87b62ca52da85ff3baa44f6b4b6 Author: Martin Uecker <uecker@tugraz.at> Date: Thu Nov 28 20:06:16 2024 +0100 c: Correct type compatibility for bit-fields [PR117828] Add missing test for consistency of bit-fields when comparing tagged types for compatibility. PR c/117828 gcc/c/ChangeLog: * c-typeck.cc (tagged_types_tu_compatible_p): Add check. gcc/testsuite/ChangeLog: * gcc.dg/c23-tag-bitfields-1.c: New test. * gcc.dg/pr117828.c: New test.
Fixed.
The master branch has been updated by Georg-Johann Lay <gjl@gcc.gnu.org>: https://gcc.gnu.org/g:846c0b397b5c1b4ff6c68d83af99aff2aa80a162 commit r15-5913-g846c0b397b5c1b4ff6c68d83af99aff2aa80a162 Author: Georg-Johann Lay <avr@gjlay.de> Date: Tue Dec 3 11:32:30 2024 +0100 Rectify some test cases. PR testsuite/52641 PR testsuite/109123 PR testsuite/114661 PR testsuite/117828 PR testsuite/116481 PR testsuite/91069 gcc/testsuite/ * gcc.dg/Wuse-after-free-pr109123.c: Use size_t instead of long unsigned int. * gcc.dg/c23-tag-bitfields-1.c: Requires int32plus. * gcc.dg/pr114661.c: Same. * gcc.dg/pr117828.c: Same. * gcc.dg/flex-array-counted-by-2.c: Use uintptr_t instead of unsigned long. * gcc.dg/pr116481.c: Same. * gcc.dg/lto/tag-1_0.c: Use int32_t instead of int. * gcc.dg/lto/tag-1_1.c: Use int16_t instead of short. * gcc.dg/pr91069.c: Require double64. * gcc.dg/type-convert-var.c: Require double64plus.