https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91793
Bug ID: 91793
Summary: [8/9/trunk regression] ICE on unexpanded parameter
pack in lambda
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cyp561 at gmail dot com
Target Milestone: ---
<eric-wieser> Managed to produce a parameter pack expansion that works in clang
trunk but not GCC trunk today: https://godbolt.org/z/PkaZqQ. No bugzilla
account, so can't report it.
<eric-wieser> Also some deliberately incorrect expansion that causes GCC to
segfault: https://godbolt.org/z/rpi-qC
Might be related to Bug 84936.
#include <initializer_list>
#include <utility>
#include <tuple>
template<typename... Funcs>
void invoke_all_of(Funcs&&... f) {
// initializer_list is special, and guarantees that the ... is expanded in
order.
(void)std::initializer_list<bool>{(void(
std::forward<Funcs>(f)()
), false)...};
}
int main() {
std::apply([](auto... a) {
invoke_all_of([&]{
using A = decltype(a);
}/*...*/);
}, std::make_tuple(1));
}
<source>: In instantiation of 'main()::<lambda(auto:1 ...)> [with auto:1 =
{int}]':
/opt/compiler-explorer/gcc-trunk-20190917/include/c++/10.0.0/type_traits:2490:26:
required by substitution of 'template<class _Fn, class ... _Args> static
std::__result_of_success<decltype (declval<_Fn>()((declval<_Args>)()...)),
std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn =
main()::<lambda(auto:1 ...)>; _Args = {int}]'
/opt/compiler-explorer/gcc-trunk-20190917/include/c++/10.0.0/type_traits:2501:55:
required from 'struct std::__result_of_impl<false, false,
main()::<lambda(auto:1 ...)>, int>'
/opt/compiler-explorer/gcc-trunk-20190917/include/c++/10.0.0/type_traits:138:12:
recursively required by substitution of 'template<class _Result, class _Ret>
struct std::__is_invocable_impl<_Result, _Ret, true, std::__void_t<typename
_CTp::type> > [with _Result = std::__invoke_result<main()::<lambda(auto:1
...)>, int>; _Ret = void]'
/opt/compiler-explorer/gcc-trunk-20190917/include/c++/10.0.0/type_traits:138:12:
required from 'struct
std::__and_<std::__is_invocable_impl<std::__invoke_result<main()::<lambda(auto:1
...)>, int>, void, true, void>,
std::__call_is_nothrow<std::__invoke_result<main()::<lambda(auto:1 ...)>, int>,
main()::<lambda(auto:1 ...)>, int> >'
/opt/compiler-explorer/gcc-trunk-20190917/include/c++/10.0.0/type_traits:2963:12:
required from 'struct std::is_nothrow_invocable<main()::<lambda(auto:1 ...)>,
int>'
/opt/compiler-explorer/gcc-trunk-20190917/include/c++/10.0.0/tuple:1603:27:
required from 'constexpr const bool std::__unpack_std_tuple<template<class _Fn,
class ... _ArgTypes> struct std::is_nothrow_invocable, main()::<lambda(auto:1
...)>, std::tuple<int> >'
/opt/compiler-explorer/gcc-trunk-20190917/include/c++/10.0.0/tuple:1631:14:
required from 'constexpr decltype(auto) std::apply(_Fn&&, _Tuple&&) [with _Fn =
main()::<lambda(auto:1 ...)>; _Tuple = std::tuple<int>]'
<source>:18:26: required from here
<source>:16:19: internal compiler error: Segmentation fault
16 | using A = decltype(a);
| ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
Leaving out the "/*" and "*/" gives: (compiles in clang)
<source>: In lambda function:
<source>:17:10: error: expansion pattern '<lambda>' contains no parameter packs
17 | }...);
| ^~~
Compiler returned: 1