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

            Bug ID: 109241
           Summary: [13 Regression] ICE Segmentation fault since for
                    ccache package r13-6722-gb323f52ccf966800
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: jason at redhat dot com
  Target Milestone: ---

Reduced from ccache package:

$ cat LocalStorage.ii
template <int __v> struct integral_constant {
  static constexpr int value = __v;
};
template <bool, typename _Tp> using __enable_if_t = _Tp;
template <typename> using __void_t = void;
template <typename _Tp> _Tp __declval(long);
template <typename _Tp> auto declval() -> decltype(__declval<_Tp>(0));
template <typename> struct __result_of_success;
template <bool, bool, typename...> struct __result_of_impl;
template <typename _Fn, typename... _Args>
__result_of_success<decltype(declval<_Fn>()(declval<_Args>...))> _S_test;
template <typename _Functor, typename... _ArgTypes>
struct __result_of_impl<false, false, _Functor, _ArgTypes...> {
  typedef decltype(_S_test<_Functor, _ArgTypes...>) type;
};
template <typename _Functor, typename... _ArgTypes>
struct __invoke_result : __result_of_impl<integral_constant<false>::value,
                                          integral_constant<false>::value,
                                          _Functor, _ArgTypes...> {};
template <typename, typename, typename = void> struct __is_invocable_impl;
template <typename _Result, typename _Ret>
struct __is_invocable_impl<_Result, _Ret, __void_t<typename _Result::type>>
    : integral_constant<true> {};
template <typename> class function;
template <typename _Cond, typename _Tp = void>
using _Requires = __enable_if_t<_Cond::value, _Tp>;
template <typename _Res, typename... _ArgTypes>
struct function<_Res(_ArgTypes...)> {
  template <typename _Func, typename _DFunc = _Func,
            typename _Res2 = __invoke_result<_DFunc, _ArgTypes...>>
  struct _Callable : __is_invocable_impl<_Res2, _Res> {};
  template <typename _Functor, typename = _Requires<_Callable<_Functor>>>
  function(_Functor) {}
};
void for_each_cache_subdir(function<void(char, function<void>)>) {
  for_each_cache_subdir([](auto, auto) {
    [](auto) {
      ({
        struct __attribute__FMT_COMPILE_STRING {};
      });
    };
  });
}

$ g++ LocalStorage.ii -c
LocalStorage.ii: In instantiation of ‘for_each_cache_subdir(function<void(char,
function<void>)>)::<lambda(auto:1, auto:2)> [with auto:1 = char (*)(); auto:2 =
function<void> (*)()]’:
LocalStorage.ii:11:44:   required from ‘struct __result_of_impl<false, false,
for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1,
auto:2)>, char, function<void> >’
LocalStorage.ii:31:10:   recursively required by substitution of
‘template<class _Result, class _Ret> struct __is_invocable_impl<_Result, _Ret,
__void_t<typename _Result::type> > [with _Result =
__invoke_result<for_each_cache_subdir(function<void(char,
function<void>)>)::<lambda(auto:1, auto:2)>, char, function<void> >; _Ret =
void]’
LocalStorage.ii:31:10:   required from ‘struct function<void(char,
function<void>)>::_Callable<for_each_cache_subdir(function<void(char,
function<void>)>)::<lambda(auto:1, auto:2)>,
for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1,
auto:2)>, __invoke_result<for_each_cache_subdir(function<void(char,
function<void>)>)::<lambda(auto:1, auto:2)>, char, function<void> > >’
LocalStorage.ii:26:7:   required by substitution of ‘template<class _Cond,
class _Tp> using _Requires = __enable_if_t<_Cond::value, _Tp> [with _Cond =
function<void(char,
function<void>)>::_Callable<for_each_cache_subdir(function<void(char,
function<void>)>)::<lambda(auto:1, auto:2)>,
for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1,
auto:2)>, __invoke_result<for_each_cache_subdir(function<void(char,
function<void>)>)::<lambda(auto:1, auto:2)>, char, function<void> > >; _Tp =
void]’
LocalStorage.ii:32:32:   required by substitution of ‘template<class _Functor,
class> function<void(char, function<void>)>::function(_Functor) [with _Functor
= for_each_cache_subdir(function<void(char, function<void>)>)::<lambda(auto:1,
auto:2)>; <template-parameter-1-2> = <missing>]’
LocalStorage.ii:36:24:   required from here
LocalStorage.ii:38:7: internal compiler error: Segmentation fault
   38 |       ({
      |       ^
0x11978cf crash_signal
        /home/marxin/Programming/gcc/gcc/toplev.cc:314
0x7ffff78b1edf ???
       
/usr/src/debug/glibc-2.37/signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0xb19347 tree_check(tree_node*, char const*, int, char const*, tree_code)
        /home/marxin/Programming/gcc/gcc/tree.h:3539
0xb19347 find_parameter_packs_r
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:4073
0x14873cd walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        /home/marxin/Programming/gcc/gcc/tree.cc:11327
0x1487a40 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*,
tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
        /home/marxin/Programming/gcc/gcc/tree.cc:11442
0xb1b105 check_for_bare_parameter_packs(tree_node*, unsigned int)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:4283
0xb7b5a5 finish_expr_stmt(tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/semantics.cc:904
0xb3c3d2 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:18856
0xb3bbb4 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:19204
0xb66e68 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:18810
0xb66e68 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:20203
0xb2f796 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:21715
0xb3977f tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:19872
0xb3ae47 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:18852
0xb3a201 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:18824
0xb3bbb4 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:19204
0xb3bbb4 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:19204
0xb46215 tsubst_expr(tree_node*, tree_node*, int, tree_node*)
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:18810
0xb46215 instantiate_body
        /home/marxin/Programming/gcc/gcc/cp/pt.cc:26815
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.

Reply via email to