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.

Reply via email to