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

--- Comment #1 from Benjamin Buch <benni.buch at gmail dot com> ---
Another version of the ICE is:

struct B{
    constexpr operator bool(){ return 1; }
};

template < typename >
void f(){
    [](auto v, auto b){
        if constexpr(b){
            auto x = [](auto){ return 0; }(v);
        }
    }(0, B{});
}

int main(){
    f<int>();
}


$ g++ -std=c++17 main.cpp
main.cpp: In instantiation of 'f() [with <template-parameter-1-1> =
int]::<lambda(auto:1, auto:2)> [with auto:1 = int; auto:2 = B]':
main.cpp:11:6:   required from 'void f() [with <template-parameter-1-1> = int]'
main.cpp:15:12:   required from here
main.cpp:9:44: internal compiler error: in tsubst_copy, at cp/pt.c:15001
             auto x = [](auto){ return 0; }(v);
                                            ^
0x611c81 tsubst_copy
        ../../gcc/gcc/cp/pt.c:15001
0x930440 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:18504
0x9328ae tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:18623
0x930d9d tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:17925
0x93f6bf tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../gcc/gcc/cp/pt.c:17345
0x93f6bf tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:17077
0x9423c2 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:14946
0x9423c2 tsubst_init
        ../../gcc/gcc/cp/pt.c:14950
0x940ec8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16391
0x93ee24 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16264
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16561
0x94097e tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16531
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16561
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16561
0x93c81f tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16561
0x93b9b8 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../gcc/gcc/cp/pt.c:16249
0x93b9b8 instantiate_decl(tree_node*, bool, bool)
        ../../gcc/gcc/cp/pt.c:23659
0x882f9b maybe_instantiate_decl
        ../../gcc/gcc/cp/decl2.c:5190
0x884fd7 mark_used(tree_node*, int)
        ../../gcc/gcc/cp/decl2.c:5291
0x7eee9a build_over_call
        ../../gcc/gcc/cp/call.c:8246
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.

$ g++ --version
g++ (GCC) 8.0.1 20180404 (experimental)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Again known to work with GCC 7:
$ g++-7 --version
g++-7 (GCC) 7.3.1 20180226
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Reply via email to