public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "juuso.alasuutari at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-114657-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            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=57911&action=edit
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=gcc-14
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 14-20240330-1'
--with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr
--with-gcc-major-version-only --program-suffix=-14
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify
--enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet
--with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/reproducible-path/gcc-14-14-20240330/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/reproducible-path/gcc-14-14-20240330/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver
--enable-checking=yes,extra,rtl --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_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) 


Compilation command
-------------------

gcc-14 -std=gnu23 -Wall -Wextra -Wpedantic -save-temps -o test test.c

             reply	other threads:[~2024-04-09 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 13:36 juuso.alasuutari at gmail dot com [this message]
2024-04-09 13:54 ` [Bug c/114657] " jakub at gcc dot gnu.org
2024-04-09 14:01 ` jakub at gcc dot gnu.org
2024-04-09 14:37 ` jsm28 at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-114657-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).