public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96815] New: internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928
@ 2020-08-27 12:26 c.de-claverie at pm dot me
  2020-08-27 12:35 ` [Bug c++/96815] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: c.de-claverie at pm dot me @ 2020-08-27 12:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96815
           Summary: internal compiler error: in tsubst_pack_expansion, at
                    cp/pt.c:12928
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: c.de-claverie at pm dot me
  Target Milestone: ---

http://coliru.stacked-crooked.com/a/ad29e1a2281d762e with v10.2.0

May be a duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96355 ?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/96815] internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928
  2020-08-27 12:26 [Bug c++/96815] New: internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928 c.de-claverie at pm dot me
@ 2020-08-27 12:35 ` redi at gcc dot gnu.org
  2020-09-08 15:09 ` jason.e.cobb at gmail dot com
  2021-11-02 19:56 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-08-27 12:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|                            |2020-08-27
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
#include <iostream>
#include <string>
#include <variant>
#include <tuple>

template<typename T>
struct A { // evtHandler
    using type = T;   
    void doStuff(T thing) { std::cout << "nice T ! " << thing << std::endl; }
};

template<typename ...args>
struct B { // module
    std::tuple<args...> As;
    B(args... _As) : As{std::make_tuple(_As...)}{};

    template<typename K>
    void dispatch(K coolObject) {
        // doStuff for As that match
        std::apply([&](auto& ... a) {
            ([&]{if constexpr(std::is_same_v<typename decltype(a)::type, K>) {
a.doStuff(coolObject); }}(), ...);
        }, As);

    }
};

template<typename ...bees>
struct C { // controller
    std::tuple<bees...> Bs;
    C(bees... _Bs) : Bs{_Bs...} {};

    template<typename L>
    void fullDispatch(L veryCoolObject) {
        // doStuff for all Bs that match
        std::apply([&](auto& ... b) {
            (b.dispatch(veryCoolObject), ...);
        }, Bs);
    }
};

int main() {
    auto b1 = B{A<int>{}, A<float>{}, A<double>{}};
    auto b2 = B{A<double>{}, A<char>{}, A<bool>{}};
    auto c = C{b1, b2};
    c.fullDispatch(12.5);
}

ICEs with -std=gnu++17

96815.C: In instantiation of 'B<args>::dispatch<double>::<lambda(auto:22& ...)>
[with auto:22 = {A<int>, A<float>, A<double>}]':
/home/jwakely/gcc/10/include/c++/10.2.1/type_traits:2506: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 =
B<args>::dispatch<double>::<lambda(auto:22& ...)>; _Args = {A<int>&, A<float>&,
A<double>&}]'
/home/jwakely/gcc/10/include/c++/10.2.1/type_traits:2517:55:   required from
'struct std::__result_of_impl<false, false,
B<args>::dispatch<double>::<lambda(auto:22& ...)>, A<int>&, A<float>&,
A<double>&>'
/home/jwakely/gcc/10/include/c++/10.2.1/type_traits:2522:12:   required from
'struct std::__invoke_result<B<args>::dispatch<double>::<lambda(auto:22& ...)>,
A<int>&, A<float>&, A<double>&>'
/home/jwakely/gcc/10/include/c++/10.2.1/type_traits:138:12:   required from
'struct
std::__and_<std::__is_invocable_impl<std::__invoke_result<B<args>::dispatch<double>::<lambda(auto:22&
...)>, A<int>&, A<float>&, A<double>&>, void, true, void>,
std::__call_is_nothrow<std::__invoke_result<B<args>::dispatch<double>::<lambda(auto:22&
...)>, A<int>&, A<float>&, A<double>&>,
B<args>::dispatch<double>::<lambda(auto:22& ...)>, A<int>&, A<float>&,
A<double>&> >'
/home/jwakely/gcc/10/include/c++/10.2.1/type_traits:2979:12:   [ skipping 7
instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/home/jwakely/gcc/10/include/c++/10.2.1/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<C<bees>::fullDispatch<double>::<lambda(auto:23& ...)>,
B<A<int>, A<float>, A<double> >&, B<A<double>, A<char>, A<bool> >&>; _Ret =
void]'
/home/jwakely/gcc/10/include/c++/10.2.1/type_traits:138:12:   required from
'struct
std::__and_<std::__is_invocable_impl<std::__invoke_result<C<bees>::fullDispatch<double>::<lambda(auto:23&
...)>, B<A<int>, A<float>, A<double> >&, B<A<double>, A<char>, A<bool> >&>,
void, true, void>,
std::__call_is_nothrow<std::__invoke_result<C<bees>::fullDispatch<double>::<lambda(auto:23&
...)>, B<A<int>, A<float>, A<double> >&, B<A<double>, A<char>, A<bool> >&>,
C<bees>::fullDispatch<double>::<lambda(auto:23& ...)>, B<A<int>, A<float>,
A<double> >&, B<A<double>, A<char>, A<bool> >&> >'
/home/jwakely/gcc/10/include/c++/10.2.1/type_traits:2979:12:   required from
'struct
std::is_nothrow_invocable<C<bees>::fullDispatch<double>::<lambda(auto:23&
...)>, B<A<int>, A<float>, A<double> >&, B<A<double>, A<char>, A<bool> >&>'
/home/jwakely/gcc/10/include/c++/10.2.1/tuple:1707:31:   required from
'constexpr const bool std::__unpack_std_tuple<template<class _Fn, class ...
_ArgTypes> struct std::is_nothrow_invocable,
C<bees>::fullDispatch<double>::<lambda(auto:23& ...)>, std::tuple<B<A<int>,
A<float>, A<double> >, B<A<double>, A<char>, A<bool> > >&>'
/home/jwakely/gcc/10/include/c++/10.2.1/tuple:1730:14:   required from
'constexpr decltype(auto) std::apply(_Fn&&, _Tuple&&) [with _Fn =
C<bees>::fullDispatch<double>::<lambda(auto:23& ...)>; _Tuple =
std::tuple<B<A<int>, A<float>, A<double> >, B<A<double>, A<char>, A<bool> >
>&]'
96815.C:35:19:   required from 'void C<bees>::fullDispatch(L) [with L = double;
bees = {B<A<int>, A<float>, A<double> >, B<A<double>, A<char>, A<bool> >}]'
96815.C:48:24:   required from here
96815.C:20:30: internal compiler error: in tsubst_pack_expansion, at
cp/pt.c:12928
   20 |         std::apply([&](auto& ... a) {
      |                        ~~~~~~^~~~~
0x5c4e33 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:12928
0x729a55 tsubst_decl
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:14243
0x73162b tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:12849
0x738f82 tsubst_fold_expr_pack
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:12462
0x738f82 tsubst_unary_right_fold
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:12578
0x738f82 tsubst_copy
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:16983
0x72cd68 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:20567
0x724f84 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:19160
0x724f84 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:18773
0x72613c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17840
0x72613c tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17885
0x7267ae tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17840
0x7267ae tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17855
0x725b2b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17840
0x725b2b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:18174
0x725b2b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17840
0x725b2b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:18174
0x7267ae tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17840
0x7267ae tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17855
0x725b2b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/jwakely/src/gcc/gcc-10/gcc/cp/pt.c:17840
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Clang rejects it as invalid:

<source>:21:55: error: type 'decltype(a)' (aka 'A<bool> &') cannot be used
prior to '::' because it has no members

            ([&]{if constexpr(std::is_same_v<typename decltype(a)::type, K>) {
a.doStuff(coolObject); }}(), ...);

                                                      ^

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/96815] internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928
  2020-08-27 12:26 [Bug c++/96815] New: internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928 c.de-claverie at pm dot me
  2020-08-27 12:35 ` [Bug c++/96815] " redi at gcc dot gnu.org
@ 2020-09-08 15:09 ` jason.e.cobb at gmail dot com
  2021-11-02 19:56 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jason.e.cobb at gmail dot com @ 2020-09-08 15:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Cobb <jason.e.cobb at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason.e.cobb at gmail dot com

--- Comment #2 from Jason Cobb <jason.e.cobb at gmail dot com> ---
I think I've stumbled upon this and have a reduced version with the same
elements (constexpr if in a lambda in a pack expansion in a lambda in a
template).

Source w/ -std=c++17:
////////

template<typename>
inline constexpr auto true_v = true;

template<typename>
auto test() {
    return [](auto... x) {
        ([]{ if constexpr (true_v<decltype(x)>); }, ...);
    }();
}

auto foo() {
    test<void>();
}

END SOURCE

Compiler output:

<source>: In instantiation of 'test<void>::<lambda(auto:1 ...)> [with auto:1 =
{}]':

<source>:8:6:   required from 'auto test() [with <template-parameter-1-1> =
void]'

<source>:12:16:   required from here

<source>:6:19: internal compiler error: in tsubst_pack_expansion, at
cp/pt.c:12952

    6 |     return [](auto... x) {

      |               ~~~~^~~~~

Please submit a full bug report,

with preprocessed source if appropriate.

See <https://gcc.gnu.org/bugs/> for instructions.

END COMPILER OUTPUT

Seen on Compiler Explorer: https://godbolt.org/z/jqEP65

This appears to ICE back through to 8.1 (as tested on Compiler Explorer). Clang
trunk accepts as valid.

GCC does not ICE if "test" is not a template or if the body of the outer-most
lambda is placed into a separate function.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/96815] internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928
  2020-08-27 12:26 [Bug c++/96815] New: internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928 c.de-claverie at pm dot me
  2020-08-27 12:35 ` [Bug c++/96815] " redi at gcc dot gnu.org
  2020-09-08 15:09 ` jason.e.cobb at gmail dot com
@ 2021-11-02 19:56 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-11-02 19:56 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looks to be the same issue as PR101764, which has been fixed for GCC 12.

*** This bug has been marked as a duplicate of bug 101764 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-02 19:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27 12:26 [Bug c++/96815] New: internal compiler error: in tsubst_pack_expansion, at cp/pt.c:12928 c.de-claverie at pm dot me
2020-08-27 12:35 ` [Bug c++/96815] " redi at gcc dot gnu.org
2020-09-08 15:09 ` jason.e.cobb at gmail dot com
2021-11-02 19:56 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).