From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 79BB33861870; Tue, 9 Apr 2024 13:36:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79BB33861870 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1712669807; bh=5CeQDkDiWpG2CK5LwD7d+TxSbYy/+QoMyUiP33GJ/HA=; h=From:To:Subject:Date:From; b=GuRPCBPLzBGnz3g7uOFeIjs04WV60HKItk/iPdDct1PLNw6n0Xln6fBLccAUJQRUq tlkugolzHbWmi3zH9gA+ct6WiFy28KHiQlne0nAFBpLAVA1u/W74hWdChX88jLjnHv 5KWO8aVcsgmc4bbRLQ0a0x13/QTICo+lMVB6thh0= From: "juuso.alasuutari at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/114657] New: Invalid type conversion from some _BitInt bit-fields Date: Tue, 09 Apr 2024 13:36:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: juuso.alasuutari at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114657 Bug ID: 114657 Summary: Invalid type conversion from some _BitInt bit-fields Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: juuso.alasuutari at gmail dot com Target Milestone: --- Created attachment 57911 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D57911&action=3Dedit Preprocessed test program source Summary ------- GCC's type conversion from some bit-precise integer-typed bit-fields does not match the description in the C23 standard. Expected vs. observed behavior ------------------------------ Based on footnote on page 47 of ISO/IEC 9899/2024 6.3.1.1 (n3320.pdf), the converted type of a _BitInt bit-field should match the original bit-precise integer: "E.g. unsigned _BitInt(7): 2 is a bit-field that can hold the values 0, 1, 2, 3, and converts to unsigned _BitInt(7)." My expectation would then be to see the following output, which does in fact happen when compiling with clang-19: $ ./test unsigned _BitInt(7) This is what GCC does: $ ./test unsigned _BitInt(2) Output of gcc-14 -v ------------------- Using built-in specs. COLLECT_GCC=3Dgcc-14 COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Debian 14-2024033= 0-1' --with-bugurl=3Dfile:///usr/share/doc/gcc-14/README.Bugs --enable-languages=3Dc,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix= =3D/usr --with-gcc-major-version-only --program-suffix=3D-14 --program-prefix=3Dx86_64-linux-gnu- --enable-shared --enable-linker-build-= id --libexecdir=3D/usr/libexec --without-included-gettext --enable-threads=3Dp= osix --libdir=3D/usr/lib --enable-nls --enable-clocale=3Dgnu --enable-libstdcxx-= debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-ve= rify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=3Drelease --with-target-system-zlib=3Dauto --enable-objc-gc=3Dauto --enable-multiarch --disable-werror --enable-cet --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --enable-offload-targets=3Dnvptx-none=3D/build/reproducible-path/gcc-14-14-= 20240330/debian/tmp-nvptx/usr,amdgcn-amdhsa=3D/build/reproducible-path/gcc-= 14-14-20240330/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=3Dyes,extra,rtl --build=3Dx86_64-linux-gnu --host=3Dx86_64-linux-gnu --target=3Dx86_64-linux-gnu Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 14.0.1 20240330 (experimental) [master r14-9728-g6fc84f680d0] (Debian 14-20240330-1)=20 Compilation command ------------------- gcc-14 -std=3Dgnu23 -Wall -Wextra -Wpedantic -save-temps -o test test.c=