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

            Bug ID: 122127
           Summary: [16 Regression]  ICE/segfault in mark_use
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mkretz at gcc dot gnu.org
  Target Milestone: ---

Test case (https://compiler-explorer.com/z/arjETK83q):

template <int> struct resize;
template <int _Np> using resize_t = resize<_Np>;
template <class _Ap> struct basic_mask {
  void _M_chunk() {
    constexpr int __rem = 1;
    [&] { resize_t<__rem>(); }();
  }
};

This was reduced from a larger (valid) code. g++ (GCC) 16.0.0 20250922 works
without issue. 20250929 was the first revision where I saw the ICE (I did not
test any in between). GCC terminates with:

<source>: In substitution of 'template<int _Np> using resize_t = resize<_Np>
[with int _Np = ((int)__rem)]':
required from here
<source>:6:25:   
    6 |     [&] { resize_t<__rem> }
      |                         ^
<source>:2:26: internal compiler error: Segmentation fault
    2 | template <int _Np> using resize_t = resize<_Np>;
      |                          ^~~~~~~~
0x28cabd8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x28bfb0b internal_error(char const*, ...)
        ???:0
0xc2eeb5 mark_use(tree_node*, bool, bool, unsigned long, bool)
        ???:0
0xd7f5c3 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
        ???:0
0xd6c03d lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
        ???:0
0xd6d4f9 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xd8984d instantiate_template(tree_node*, tree_node*, int)
        ???:0
0xd6c47e lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int)
        ???:0
0xdbba2c finish_template_type(tree_node*, tree_node*, int)
        ???:0
0xd35b83 c_parse_file()
        ???:0
0xea5f99 c_common_parse_file()
        ???:0

Reply via email to