public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cuzdav at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/114706] New: ICE - std::bit_cast in consteval function involving union
Date: Fri, 12 Apr 2024 20:13:31 +0000	[thread overview]
Message-ID: <bug-114706-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 114706
           Summary: ICE - std::bit_cast in consteval function involving
                    union
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: cuzdav at gmail dot com
  Target Milestone: ---

ICE in a consteval function bit_casting an array of unions.  The code isn't
valid due to the union, but the compiler is not handling it properly (since
gcc11...trunk).  Reduced to the following program:

CODE

    #include <bit>
    union U { int u; };
    consteval void f() {
        U result[]{0, 0};   
        auto x = std::bit_cast<long>(result);
    }
    int main() { f(); }

LIVE:
https://godbolt.org/z/Y943bc5zK


OUTPUT

/opt/compiler-explorer/gcc-trunk-20240412/include/c++/14.0.1/bit:94:33:
internal compiler error: in native_encode_initializer, at fold-const.cc:8468
   94 |       return __builtin_bit_cast(_To, __from);
      |                                 ^~~
0x267826c internal_error(char const*, ...)
        ???:0
0xa58c63 fancy_abort(char const*, int, char const*)
        ???:0
0xfa0eaf native_encode_initializer(tree_node*, unsigned char*, int, int,
unsigned char*)
        ???:0
0xacf0f0 maybe_constant_value(tree_node*, tree_node*, mce_value)
        ???:0
0xd3a75f store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xb474fe cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xc5c81a c_parse_file()
        ???:0
0xdb1489 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

             reply	other threads:[~2024-04-12 20:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12 20:13 cuzdav at gmail dot com [this message]
2024-04-12 20:17 ` [Bug c++/114706] " pinskia at gcc dot gnu.org
2024-04-12 20:21 ` [Bug c++/114706] ICE - std::bit_cast in consteval function involving array of union pinskia at gcc dot gnu.org
2024-04-15 15:40 ` jakub at gcc dot gnu.org
2024-04-16  8:02 ` jakub at gcc dot gnu.org
2024-04-16  8:02 ` jakub 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-114706-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).