[Bug c++/60033] New: gcc 4.9.0 20140107: ICE in retrieve_specialization while compiling recursive generic lambda

vock at cs dot uni-bonn.de gcc-bugzilla@gcc.gnu.org
Sun Feb 2 19:54:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60033

            Bug ID: 60033
           Summary: gcc 4.9.0 20140107: ICE in retrieve_specialization
                    while compiling recursive generic lambda
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vock at cs dot uni-bonn.de

Created attachment 32016
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32016&action=edit
Preprocessed output file

I got an ICE while compiling the following minimal code example (.ii is
attached):


//#include <iostream>
#include <utility>

template <typename... Funcs>
struct composer;

template <typename Func>
struct composer<Func> {
    auto operator()(Func&& f) {
        return f;
    }
};

template <typename Func, typename... Funcs>
struct composer<Func, Funcs...> {
    auto operator()(Func&& f, Funcs&&... fs) {
        composer<Funcs...> c;
        return [&] (auto v) {
            return f(composer<Funcs...>()(std::forward<Funcs>(fs)...)(v));
        };
    }
};

template <typename... Funcs>
auto compose(Funcs&&... fs) {
    return composer<Funcs...>()(std::forward<Funcs>(fs)...);
}


int main (int argc, char const* argv[]) {
    float v = 3.5f;
    auto func = [] (auto v) { return int(v-0.5); };
    auto t = compose([] (auto v) { return v >= 3; }, func)(v);
//    std::cout << std::boolalpha << t << "\n";
    auto f = compose([] (auto v) { return v > 3; }, func)(v);
//    std::cout << std::boolalpha << f << "\n";
}


Compiler output is:

> g++-4.9 -std=c++1y -save-temps -Wall -Wextra -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations main.cpp

main.cpp: In instantiation of ‘composer<Func, Funcs ...>::operator()(Func&&,
Funcs&& ...)::<lambda(auto:2)> [with auto:2 = float; Func = main(int, const
char**)::<lambda(auto:3)>; Funcs = {main(int, const
char**)::<lambda(auto:4)>}]’:
main.cpp:33:88:   required from here
main.cpp:19:41: internal compiler error: in retrieve_specialization, at
cp/pt.c:1042
    return f(c(std::forward<Funcs>(fs)...)(v));
                                         ^
0x59c47f retrieve_specialization
    ./src/gcc/gcc/cp/pt.c:1039
0x5a470c tsubst_pack_expansion
    ./src/gcc/gcc/cp/pt.c:9563
0x59f404 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
    ./src/gcc/gcc/cp/pt.c:14461
0x59fa18 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
    ./src/gcc/gcc/cp/pt.c:14443
0x59f3a0 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
    ./src/gcc/gcc/cp/pt.c:14456
0x5a31ce tsubst_expr
    ./src/gcc/gcc/cp/pt.c:13788
0x5a31a4 tsubst_expr
    ./src/gcc/gcc/cp/pt.c:13205
0x5a316f tsubst_expr
    ./src/gcc/gcc/cp/pt.c:13400
0x5a2e34 tsubst_expr
    ./src/gcc/gcc/cp/pt.c:13195
0x5a316f tsubst_expr
    ./src/gcc/gcc/cp/pt.c:13400
0x5a2038 instantiate_decl(tree_node*, int, bool)
    ./src/gcc/gcc/cp/pt.c:19656
0x5cfbb9 mark_used(tree_node*, int)
    ./src/gcc/gcc/cp/decl2.c:4701
0x57760b build_over_call
    ./src/gcc/gcc/cp/call.c:7127
0x57a301 build_op_call_1
    ./src/gcc/gcc/cp/call.c:4161
0x57a301 build_op_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
    ./src/gcc/gcc/cp/call.c:4184
0x636cf8 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
    ./src/gcc/gcc/cp/semantics.c:2298
0x5ec24b cp_parser_postfix_expression
    ./src/gcc/gcc/cp/parser.c:6165
0x5ee8b8 cp_parser_unary_expression
    ./src/gcc/gcc/cp/parser.c:7171
0x5ef48f cp_parser_binary_expression
    ./src/gcc/gcc/cp/parser.c:7875
0x5ef951 cp_parser_assignment_expression
    ./src/gcc/gcc/cp/parser.c:8113




A running version compiled using clang++ 3.5 is here:
http://coliru.stacked-crooked.com/a/acc691b9a407d6f2




System:

Arch Linux
Linux xxx 3.12.6-1-ARCH #1 SMP PREEMPT Fri Dec 20 19:39:00 CET 2013 x86_64
GNU/Linux

Build Command:

g++-4.9 -std=c++1y -save-temps -Wall -Wextra -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations main.cpp


Version:

Using built-in specs.
COLLECT_GCC=g++-4.9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--datadir=/usr/share/gcc-4.9
--with-bugurl='http://aur.archlinux.org/packages.php?ID=16045'
--enable-languages=c,c++,lto --enable-shared --enable-threads=posix
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-clocale=gnu --disable-libstdcxx-pch --enable-gnu-unique-object
--enable-linker-build-id --enable-cloog-backend=isl
--disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default
--enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu
--disable-install-libiberty --disable-multilib --disable-libssp
--disable-werror --enable-checking=release --program-suffix=-4.9
--enable-version-specific-runtime-libs
Thread model: posix
gcc version 4.9.0 20140107 (experimental) (GCC)


More information about the Gcc-bugs mailing list