Bug 104646 - [9 Regression] ICE in cx_check_missing_mem_inits, at cp/constexpr.cc:845
Summary: [9 Regression] ICE in cx_check_missing_mem_inits, at cp/constexpr.cc:845
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P2 normal
Target Milestone: 9.5
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2022-02-22 19:30 UTC by G. Steinmetz
Modified: 2022-05-13 17:50 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2022-02-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2022-02-22 19:30:48 UTC
Seems to have started with r7 (r6 seems to compile it) :
(gcc configured with --enable-checking=yes)


$ cat z1.cc
#include <regex>
#include <string>
int main() {
  const std::string str = "abc";
  std::regex re;
  re = std::regex("^[0-9]$");
  return std::regex_search(str, re);
}


$ g++-12-20220220 -c z1.cc -fno-elide-constructors
In file included from .../include/c++/12.0.1/bits/stl_algobase.h:64,
                 from .../include/c++/12.0.1/string:50,
                 from .../include/c++/12.0.1/bitset:47,
                 from .../include/c++/12.0.1/regex:38,
                 from z1.cc:1:
.../include/c++/12.0.1/bits/stl_pair.h: In instantiation of 'void std::__detail::_Executor< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <anonymous> >::_M_rep_once_more(_Match_mode, std::__detail::_StateIdT) [with _BiIter = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _TraitsT = std::__cxx11::regex_traits<char>; bool __dfs_mode = false; std::__detail::_StateIdT = long int]':
.../include/c++/12.0.1/bits/regex_executor.tcc:212:4:   required from 'void std::__detail::_Executor< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <anonymous> >::_M_handle_repeat(_Match_mode, std::__detail::_StateIdT) [with _BiIter = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _TraitsT = std::__cxx11::regex_traits<char>; bool __dfs_mode = false; std::__detail::_StateIdT = long int]'
.../include/c++/12.0.1/bits/regex_executor.tcc:515:4:   required from 'void std::__detail::_Executor< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <anonymous> >::_M_dfs(_Match_mode, std::__detail::_StateIdT) [with _BiIter = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _TraitsT = std::__cxx11::regex_traits<char>; bool __dfs_mode = false; std::__detail::_StateIdT = long int]'
.../include/c++/12.0.1/bits/regex_executor.tcc:130:8:   required from 'bool std::__detail::_Executor< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <anonymous> >::_M_main_dispatch(_Match_mode, __bfs) [with _BiIter = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _TraitsT = std::__cxx11::regex_traits<char>; bool __dfs_mode = false; __bfs = std::integral_constant<bool, false>]'
.../include/c++/12.0.1/bits/regex_executor.h:149:32:   required from 'bool std::__detail::_Executor< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <anonymous> >::_M_main(_Match_mode) [with _BiIter = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _TraitsT = std::__cxx11::regex_traits<char>; bool __dfs_mode = false]'
.../include/c++/12.0.1/bits/regex_executor.h:93:9:   required from 'bool std::__detail::_Executor< <template-parameter-1-1>, <template-parameter-1-2>, <template-parameter-1-3>, <anonymous> >::_M_match() [with _BiIter = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _TraitsT = std::__cxx11::regex_traits<char>; bool __dfs_mode = false]'
.../include/c++/12.0.1/bits/regex.tcc:71:33:   required from 'bool std::__detail::__regex_algo_impl(_BiIter, _BiIter, std::__cxx11::match_results<_BiIter, _Alloc>&, const std::__cxx11::basic_regex<_CharT, _TraitsT>&, std::regex_constants::match_flag_type, _RegexExecutorPolicy, bool) [with _BiIter = __gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, std::__cxx11::basic_string<char> > > >; _CharT = char; _TraitsT = std::__cxx11::regex_traits<char>]'
.../include/c++/12.0.1/bits/regex.h:2364:41:   required from 'bool std::regex_search(_Bi_iter, _Bi_iter, __cxx11::match_results<_BiIter, _Alloc>&, const __cxx11::basic_regex<_CharT, _TraitsT>&, regex_constants::match_flag_type) [with _Bi_iter = __gnu_cxx::__normal_iterator<const char*, __cxx11::basic_string<char> >; _Alloc = allocator<__cxx11::sub_match<__gnu_cxx::__normal_iterator<const char*, __cxx11::basic_string<char> > > >; _Ch_type = char; _Rx_traits = __cxx11::regex_traits<char>]'
.../include/c++/12.0.1/bits/regex.h:2387:26:   required from 'bool std::regex_search(_Bi_iter, _Bi_iter, const __cxx11::basic_regex<_Ch_type, _Rx_traits>&, regex_constants::match_flag_type) [with _Bi_iter = __gnu_cxx::__normal_iterator<const char*, __cxx11::basic_string<char> >; _Ch_type = char; _Rx_traits = __cxx11::regex_traits<char>]'
.../include/c++/12.0.1/bits/regex.h:2447:26:   required from 'bool std::regex_search(const __cxx11::basic_string<_Ch_type, _Ch_traits, _Str_allocator>&, const __cxx11::basic_regex<_CharT, _TraitsT>&, regex_constants::match_flag_type) [with _Ch_traits = char_traits<char>; _String_allocator = allocator<char>; _Ch_type = char; _Rx_traits = __cxx11::regex_traits<char>]'
z1.cc:7:27:   required from here
.../include/c++/12.0.1/bits/stl_pair.h:195:17: internal compiler error: in cx_check_missing_mem_inits, at cp/constexpr.cc:845
  195 |       constexpr pair(const pair&) = default;    ///< Copy constructor
      |                 ^~~~
0x766de6 cx_check_missing_mem_inits
        ../../gcc/cp/constexpr.cc:844
0x77e001 cx_check_missing_mem_inits
        ../../gcc/cp/constexpr.cc:969
0x77e001 maybe_save_constexpr_fundef(tree_node*)
        ../../gcc/cp/constexpr.cc:925
0x803fe1 finish_function(bool)
        ../../gcc/cp/decl.cc:17815
0x882bd3 synthesize_method(tree_node*)
        ../../gcc/cp/method.cc:1837
0x81dc24 mark_used(tree_node*, int)
        ../../gcc/cp/decl2.cc:5960
0x72d4d9 build_over_call
        ../../gcc/cp/call.cc:9850
0x731bef build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int)
        ../../gcc/cp/call.cc:11139
0x733888 build_special_member_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, int)
        ../../gcc/cp/call.cc:10613
0x7beca6 ocp_convert(tree_node*, tree_node*, int, int, int)
        ../../gcc/cp/cvt.cc:956
0x8473f3 expand_default_init
        ../../gcc/cp/init.cc:2127
0x8473f3 expand_aggr_init_1
        ../../gcc/cp/init.cc:2313
0x849d18 build_aggr_init(tree_node*, tree_node*, int, int)
        ../../gcc/cp/init.cc:2033
0x7d910f build_aggr_init_full_exprs
        ../../gcc/cp/decl.cc:7058
0x7d910f check_initializer
        ../../gcc/cp/decl.cc:7219
0x8078d6 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/cp/decl.cc:8247
0x996dc4 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.cc:18615
0x992238 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.cc:18423
0x9938d3 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.cc:18780
0x99640c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/cp/pt.cc:18749
Comment 1 Marek Polacek 2022-02-22 20:19:14 UTC
Started with r7-2144.
Comment 2 Marek Polacek 2022-02-22 20:58:22 UTC
Somewhat reduced:

template <typename _T1> struct pair {
  _T1 first;
  int second;
};
template <typename _Iterator> class __normal_iterator {
  _Iterator __traits_type;

public:
  constexpr __normal_iterator() {}
};
template <typename> class allocator;
template <typename> struct allocator_traits;
template <typename _Tp> struct allocator_traits<allocator<_Tp>> {
  using value_type = _Tp;
  template <typename _Up> using rebind_alloc = allocator<_Up>;
};
template <typename _Alloc> struct __alloc_traits {
  typedef allocator_traits<_Alloc> _Base_type;
  typedef typename _Base_type::value_type &const_reference;
  template <typename _Tp> struct rebind {
    typedef typename _Base_type::template rebind_alloc<_Tp> other;
  };
};
template <typename _Tp, typename _Alloc> struct _Vector_base {
  typedef typename __alloc_traits<_Alloc>::template rebind<_Tp>::other _Tp_alloc_type;
};
template <typename _Tp, typename _Alloc = allocator<_Tp>> class vector {
public:
  typename __alloc_traits<
      typename _Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_reference
  operator[](long);
};
enum match_flag_type {};
template <typename, typename> class Trans_NS___cxx11_basic_regex;
class Trans_NS___cxx11_match_results;
enum _RegexExecutorPolicy { _S_auto };
template <typename, typename, typename _CharT, typename _TraitsT,
          _RegexExecutorPolicy, bool>
bool __regex_algo_impl(Trans_NS___cxx11_match_results &,
                       const Trans_NS___cxx11_basic_regex<_CharT, _TraitsT> &);
template <typename, typename, typename, bool> class _Executor;
template <typename _Ch_type, typename = _Ch_type>
class Trans_NS___cxx11_basic_regex {};
class Trans_NS___cxx11_match_results : vector<int> {
  template <typename, typename, typename _Cp, typename _Rp,
            _RegexExecutorPolicy, bool>
  friend bool __regex_algo_impl(Trans_NS___cxx11_match_results &,
                                const Trans_NS___cxx11_basic_regex<_Cp, _Rp> &);
};
template <typename _Bi_iter, typename _Alloc, typename _Ch_type,
          typename _Rx_traits>
void regex_search(_Bi_iter, _Alloc,
                  Trans_NS___cxx11_basic_regex<_Ch_type, _Rx_traits>) {
  __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits, _S_auto, false>;
}
match_flag_type __regex_algo_impl___flags;
template <typename, typename, typename _CharT, typename _TraitsT,
          _RegexExecutorPolicy, bool>
bool __regex_algo_impl(
    Trans_NS___cxx11_match_results &__m,
    const Trans_NS___cxx11_basic_regex<_CharT, _TraitsT> &__re) {
  __normal_iterator<const char *> __e, __s;
  _Executor<int, int, _TraitsT, false> __executor(__s, __e, __m, __re,
                                                  __regex_algo_impl___flags);
  __executor._M_match();
  return false;
}
template <typename, typename, typename, bool> class _Executor {
public:
  _Executor(__normal_iterator<const char *>, __normal_iterator<const char *>,
            vector<int>, Trans_NS___cxx11_basic_regex<char>, match_flag_type);
  void _M_match() { _M_dfs(); }
  void _M_dfs();
  vector<pair<__normal_iterator<char *>>> _M_rep_count;
};
long _M_rep_once_more___i;
template <typename _BiIter, typename _Alloc, typename _TraitsT, bool __dfs_mode>
void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::_M_dfs() {
  auto __rep_count = _M_rep_count[_M_rep_once_more___i];
}
char main___trans_tmp_1;
void main___trans_tmp_2() {
  Trans_NS___cxx11_basic_regex<char> re;
  regex_search(main___trans_tmp_1, main___trans_tmp_2, re);
}
Comment 3 GCC Commits 2022-04-14 21:10:49 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:c5de3444c4798758cdd800eca144480b4a8ef299

commit r12-8167-gc5de3444c4798758cdd800eca144480b4a8ef299
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 15:34:14 2022 -0400

    c++: constexpr trivial -fno-elide-ctors [PR104646]
    
    The constexpr constructor checking code got confused by the expansion of a
    trivial copy constructor; we don't need to do that checking for defaulted
    ctors, anyway.
    
            PR c++/104646
    
    gcc/cp/ChangeLog:
    
            * constexpr.cc (maybe_save_constexpr_fundef): Don't do extra
            checks for defaulted ctors.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/constexpr-fno-elide-ctors1.C: New test.
Comment 4 GCC Commits 2022-05-12 20:14:39 UTC
The releases/gcc-11 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:a67bc6320d34b20fe838d479a6a1e110f1160c89

commit r11-9987-ga67bc6320d34b20fe838d479a6a1e110f1160c89
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 15:34:14 2022 -0400

    c++: constexpr trivial -fno-elide-ctors [PR104646]
    
    The constexpr constructor checking code got confused by the expansion of a
    trivial copy constructor; we don't need to do that checking for defaulted
    ctors, anyway.
    
            PR c++/104646
    
    gcc/cp/ChangeLog:
    
            * constexpr.c (maybe_save_constexpr_fundef): Don't do extra
            checks for defaulted ctors.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/constexpr-fno-elide-ctors1.C: New test.
Comment 5 GCC Commits 2022-05-12 21:23:26 UTC
The releases/gcc-10 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:d939233ef460133e012d8f40f9d8c8fcb73bb7b8

commit r10-10725-gd939233ef460133e012d8f40f9d8c8fcb73bb7b8
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 15:34:14 2022 -0400

    c++: constexpr trivial -fno-elide-ctors [PR104646]
    
    The constexpr constructor checking code got confused by the expansion of a
    trivial copy constructor; we don't need to do that checking for defaulted
    ctors, anyway.
    
            PR c++/104646
    
    gcc/cp/ChangeLog:
    
            * constexpr.c (maybe_save_constexpr_fundef): Don't do extra
            checks for defaulted ctors.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/constexpr-fno-elide-ctors1.C: New test.
Comment 6 GCC Commits 2022-05-13 17:41:39 UTC
The releases/gcc-9 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:7b4bd8dbd8d07e298528b0f033102ce8f693e739

commit r9-10171-g7b4bd8dbd8d07e298528b0f033102ce8f693e739
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Apr 14 15:34:14 2022 -0400

    c++: constexpr trivial -fno-elide-ctors [PR104646]
    
    The constexpr constructor checking code got confused by the expansion of a
    trivial copy constructor; we don't need to do that checking for defaulted
    ctors, anyway.
    
            PR c++/104646
    
    gcc/cp/ChangeLog:
    
            * constexpr.c (maybe_save_constexpr_fundef): Don't do extra
            checks for defaulted ctors.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/constexpr-fno-elide-ctors1.C: New test.
Comment 7 Jason Merrill 2022-05-13 17:50:26 UTC
Fixed for 9.5/10.4/11.4/12.