简单的boost :: hana示例会产生内部编译器错误

时间:2017-05-24 00:52:54

标签: c++ boost internal-compiler-error

尝试boost::hana(版本1.1.0),并使用g ++ 6.2.0进行编译,我得到了该示例的编译器错误:

#include <boost/hana.hpp>
#include <iostream>
#include <type_traits>

struct my_tag {};

namespace boost {
    namespace hana {

        template<class T>
        struct tag_of<T, when<std::is_same<T, int>{}> >
        {
            using type = my_tag;
        };

    }
}

int main()
{
    std::cout << std::is_same<my_tag, 
                              boost::hana::tag_of<int>::type>::value
              << std::endl;
}

编译器生成内部错误:

In file included from /usr/local/include/boost/hana/concept/struct.hpp:18:0,
                 from /usr/local/include/boost/hana/accessors.hpp:15,
                 from /usr/local/include/boost/hana.hpp:58,
                 from main.cpp:1:
/usr/local/include/boost/hana/core/tag_of.hpp: In instantiation of ‘struct boost::hana::tag_of<int>’:
main.cpp:21:63:   required from here
/usr/local/include/boost/hana/core/tag_of.hpp:22:12: internal compiler error: in unify, at cp/pt.c:20188
     struct tag_of : tag_of<T, when<true>> { };
            ^~~~~~
0x61cda8 unify
    ../../src/gcc/cp/pt.c:20188
0x61d094 unify
    ../../src/gcc/cp/pt.c:19980
0x61cadf unify
    ../../src/gcc/cp/pt.c:20059
0x61d094 unify
    ../../src/gcc/cp/pt.c:19980
0x61de46 get_partial_spec_bindings
    ../../src/gcc/cp/pt.c:20749
0x61a69c most_specialized_partial_spec
    ../../src/gcc/cp/pt.c:21021
0x625123 instantiate_class_template_1
    ../../src/gcc/cp/pt.c:9812
0x625123 instantiate_class_template(tree_node*)
    ../../src/gcc/cp/pt.c:10377
0x686c8d complete_type(tree_node*)
    ../../src/gcc/cp/typeck.c:131
0x686d2f complete_type_or_maybe_complain(tree_node*, tree_node*, int)
    ../../src/gcc/cp/typeck.c:143
0x5ef539 xref_basetypes(tree_node*, tree_node*)
    ../../src/gcc/cp/decl.c:12933
0x6253f5 instantiate_class_template_1
    ../../src/gcc/cp/pt.c:9966
0x6253f5 instantiate_class_template(tree_node*)
    ../../src/gcc/cp/pt.c:10377
0x686c8d complete_type(tree_node*)
    ../../src/gcc/cp/typeck.c:131
0x665463 cp_parser_nested_name_specifier_opt
    ../../src/gcc/cp/parser.c:6104
0x663401 cp_parser_simple_type_specifier
    ../../src/gcc/cp/parser.c:16255
0x65fcad cp_parser_type_specifier
    ../../src/gcc/cp/parser.c:15936
0x661f52 cp_parser_type_specifier_seq
    ../../src/gcc/cp/parser.c:20059
0x66a662 cp_parser_type_id_1
    ../../src/gcc/cp/parser.c:19921
0x66a77e cp_parser_template_type_arg
    ../../src/gcc/cp/parser.c:19980
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-6/README.Bugs> for instructions.

这是一个gcc bug吗?任何人都可以尝试复制此错误吗?

0 个答案:

没有答案