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

            Bug ID: 116676
           Summary: GCC crashes on incorrect code with -std=c++23 in
                    'constexpr' expansion of 'std::get<0, const int&,
                    details::spin_sync<void> >(std::<structured
                    bindings>)'
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: q1210081098 at gmail dot com
  Target Milestone: ---

Reproducer: https://gcc.godbolt.org/z/xchx7s3f7
```
#include <iostream>
namespace std {
    namespace details {
        template<typename>
        class spin_sync{ };
        template<>
        class spin_sync<void>{ };
    }
    constexpr int x(3);
    auto [fet, err] = std::pair<const int &, details::spin_sync<void> >{ x*x,
details::spin_sync<void>() };
    return 0;
}

```
and get result
```
In file included from
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/bits/stl_algobase.h:64,
                 from
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/string:51,
                 from
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/bits/locale_classes.h:40,
                 from
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/bits/ios_base.h:41,
                 from
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/ios:44,
                 from
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/ostream:40,
                 from
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/iostream:41,
                 from <source>:1:
<source>:10:11:   in 'constexpr' expansion of 'std::get<0, const int&,
details::spin_sync<void> >(std::<structured bindings>)'
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/bits/stl_pair.h:1270:42:
  in 'constexpr' expansion of 'std::__pair_get<0>::__move_get<const int&,
std::details::spin_sync<void> >((* & std::move<pair<const int&,
details::spin_sync<void> >&>((* & __in))))'
/opt/compiler-explorer/gcc-trunk-20240911/include/c++/15.0.0/bits/stl_pair.h:1220:44:
internal compiler error: Segmentation fault
 1220 |         { return std::forward<_Tp1>(__pair.first); }
      |                                     ~~~~~~~^~~~~
0x27e5ad5 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
        ???:0
0x27f9075 internal_error(char const*, ...)
        ???:0
0xd6fcad store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xb7523e cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xb72f8d cp_finish_decomp(tree_node*, cp_decomp*, bool)
        ???:0
0xb7518c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int,
cp_decomp*)
        ???:0
0xc9050a c_parse_file()
        ???:0
0xde72f9 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.
Compiler returned: 1
```

Reply via email to