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

            Bug ID: 60216
           Summary: [4.8/4.9 Regression] [c++11] Trouble with deleted
                    template functions
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: reichelt at gcc dot gnu.org

The following invalid code snippet (compiled with "-std=c++11") triggers an
ICE since GCC 4.8.1:

============================================
struct A
{
  template<typename T> A(T) = delete;
};

template<> A::A<int>(int) {}

A a(0);
============================================

bug.cc:8:6: error: use of deleted function 'A::A(T) [with T = int]'
 A a(0);
      ^
bug.cc:8:6: internal compiler error: in maybe_explain_implicit_delete, at
cp/method.c:1422
0x7177c2 maybe_explain_implicit_delete(tree_node*)
        ../../gcc/gcc/cp/method.c:1422
0x6871f8 mark_used(tree_node*, int)
        ../../gcc/gcc/cp/decl2.c:4656
0x5b1349 build_over_call
        ../../gcc/gcc/cp/call.c:7188
0x5b3d0a build_new_method_call_1
        ../../gcc/gcc/cp/call.c:7887
0x5b3d0a build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ../../gcc/gcc/cp/call.c:7957
0x5b4d79 build_special_member_call(tree_node*, tree_node*, vec<tree_node*,
va_gc, vl_embed>**, tree_node*, int, int)
        ../../gcc/gcc/cp/call.c:7513
0x7080e9 expand_default_init
        ../../gcc/gcc/cp/init.c:1677
0x7080e9 expand_aggr_init_1
        ../../gcc/gcc/cp/init.c:1778
0x70adf3 build_aggr_init(tree_node*, tree_node*, int, int)
        ../../gcc/gcc/cp/init.c:1529
0x5c7454 build_aggr_init_full_exprs
        ../../gcc/gcc/cp/decl.c:5591
0x5c7454 check_initializer
        ../../gcc/gcc/cp/decl.c:5727
0x5d99fc cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../gcc/gcc/cp/decl.c:6396
0x6c81bd cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:16815
0x6c9979 cp_parser_simple_declaration
        ../../gcc/gcc/cp/parser.c:11205
0x6acc63 cp_parser_block_declaration
        ../../gcc/gcc/cp/parser.c:11086
0x6d3f12 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:10983
0x6d2c08 cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:10869
0x6d44aa cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4014
0x6d44aa c_parse_file()
        ../../gcc/gcc/cp/parser.c:31536
0x7f3813 c_common_parse_file()
        ../../gcc/gcc/c-family/c-opts.c:1060
Please submit a full bug report, [etc.]

A similar testcase is wrongly accepted since GCC 4.8.1:

============================================
struct A
{
  template<typename T> void foo(T) = delete;
};

template<> void A::foo<int>(int) {}

void bar()
{
  A().foo(0);
}
============================================

Reply via email to