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

            Bug ID: 123677
           Summary: [16 Regression] ICE: tree check: expected constructor,
                    have ptrmem_cst in cxx_eval_store_expression, at
                    cp/constexpr.cc
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jirehguo at tju dot edu.cn
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/Tx476nWaM
The following c++ code crash gcc trunk with -std=c++20 flag.
But clang and 13,14,15 with checking accept this code.


Code:
```cpp
#include <functional>
class C {
public:
  void func1();
  void func2();
};
std::vector<std::vector<void (C::*)()>> farr = {{&C::func1, &C::func2}};
```

Stack dump:
```
In file included from
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/bits/stl_iterator.h:78,
                 from
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/bits/ranges_base.h:39,
                 from
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/bits/ranges_util.h:34,
                 from
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/tuple:46,
                 from
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/functional:71,
                 from <source>:1:
in 'constexpr' expansion of '((std::vector<void
(C::*)()>*)<anonymous>)->std::vector<void (C::*)()>::~vector()'
<source>:7:71:   
    7 | std::vector<std::vector<void (C::*)()>> farr = {{&C::func1,
&C::func2}};
      |                                                                       ^
in 'constexpr' expansion of 'std::_Destroy<void (C::**)(), void
(C::*)()>(((std::vector<void (C::*)()>*)this)->std::vector<void
(C::*)()>::std::_Vector_base<void (C::*)(), std::allocator<void (C::*)()>
>.std::_Vector_base<void (C::*)(), std::allocator<void (C::*)()>
>::_M_impl.std::_Vector_base<void (C::*)(), std::allocator<void (C::*)()>
>::_Vector_impl::std::_Vector_base<void (C::*)(), std::allocator<void (C::*)()>
>::_Vector_impl_data.std::_Vector_base<void (C::*)(), std::allocator<void
(C::*)()> >::_Vector_impl_data::_M_start, ((std::vector<void
(C::*)()>*)this)->std::vector<void (C::*)()>::std::_Vector_base<void (C::*)(),
std::allocator<void (C::*)()> >.std::_Vector_base<void (C::*)(),
std::allocator<void (C::*)()> >::_M_impl.std::_Vector_base<void (C::*)(),
std::allocator<void (C::*)()> >::_Vector_impl::std::_Vector_base<void (C::*)(),
std::allocator<void (C::*)()> >::_Vector_impl_data.std::_Vector_base<void
(C::*)(), std::allocator<void (C::*)()> >::_Vector_impl_data::_M_finish, (*
&((std::vector<void (C::*)()>*)this)->std::vector<void
(C::*)()>::std::_Vector_base<void (C::*)(), std::allocator<void (C::*)()>
>.std::_Vector_base<void (C::*)(), std::allocator<void (C::*)()>
>::_M_get_Tp_allocator()))'
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/bits/stl_vector.h:792:15:
 
  792 |         std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
      |         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  793 |                       _M_get_Tp_allocator());
      |                       ~~~~~~~~~~~~~~~~~~~~~~
in 'constexpr' expansion of 'std::_Destroy<void (C::**)()>(__first, __last)'
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/bits/alloc_traits.h:1045:20:
 
 1045 |       std::_Destroy(__first, __last);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
in 'constexpr' expansion of 'std::destroy_at<void (C::*)()>(std::addressof<void
(C::*)()>((* __first)))'
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/bits/stl_construct.h:230:19:
 
  230 |           std::destroy_at(std::addressof(*__first));
      |           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/cefs/fb/fbb1812a35f407668b457d10_gcc-trunk-20260118/include/c++/16.0.1/bits/stl_construct.h:88:9:
internal compiler error: tree check: expected constructor, have ptrmem_cst in
cxx_eval_store_expression, at cp/constexpr.cc:8201
   88 |         __location->~_Tp();
      |         ^~~~~~~~~~
0x2950a78 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x294583b internal_error(char const*, ...)
        ???:0
0xa234d1 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xb8b38f cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c785 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c2d0 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8ebc4 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c554 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c785 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c2d0 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8b893 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8ebc4 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8ebc4 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8bfd0 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c554 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c785 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c2d0 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c554 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c785 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???:0
0xb8c2d0 cxx_eval_constant_expression(constexpr_ctx const*, tree_node*,
value_cat, bool*, bool*, tree_node**)
        ???: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