public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114706] New: ICE - std::bit_cast in consteval function involving union
@ 2024-04-12 20:13 cuzdav at gmail dot com
  2024-04-12 20:17 ` [Bug c++/114706] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: cuzdav at gmail dot com @ 2024-04-12 20:13 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-04-16  8:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-12 20:13 [Bug c++/114706] New: ICE - std::bit_cast in consteval function involving union cuzdav at gmail dot com
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

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).