https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71630
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-06-24
CC| |marxin at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
There's another test-case:
template <class T>
extern T pi;
int main()
{
return pi<int>;
}
where we ICE on the following VAR_DECL:
(gdb) p debug_tree(decl)
<var_decl 0x7ffff7fedd80 pi
type <integer_type 0x7ffff68857e0 int public type_6 SI
size <integer_cst 0x7ffff68a20a8 constant 32>
unit size <integer_cst 0x7ffff68a20c0 constant 4>
align 32 symtab 0 alias set -1 canonical type 0x7ffff68857e0 precision
32 min <integer_cst 0x7ffff68a2060 -2147483648> max <integer_cst 0x7ffff68a2078
2147483647>
pointer_to_this <pointer_type 0x7ffff68a6930>>
used public tree_1 decl_1 decl_2 SI file /tmp/t.c line 2 col 10 size
<integer_cst 0x7ffff68a20a8 32> unit size <integer_cst 0x7ffff68a20c0 4>
align 32 context <translation_unit_decl 0x7ffff688d168 D.1>
template-info 0x7ffff69df980>
I guess the problem is that the declaration does not have DECL_EXTERNAL flag
set.
When I tried to link the code snippet (by clang++) with another one, where the
symbol is defined,
it worked fine.
My code snippet is problem also in GCC 5.3.1 and GCC 6.1.1 with the following
back trace:
/tmp/t.c: In function ‘int main()’:
/tmp/t.c:6:10: internal compiler error: in ctor_for_folding, at varpool.c:419
return pi<int>;
^~~~~~~
0xd17330 ctor_for_folding(tree_node*)
../../gcc/varpool.c:419
0x8e6c78 get_symbol_constant_value(tree_node*)
../../gcc/gimple-fold.c:228
0x8ef7be fold_gimple_assign
../../gcc/gimple-fold.c:396
0x8ef7be fold_stmt_1
../../gcc/gimple-fold.c:3710
0x905efa gimplify_modify_expr
../../gcc/gimplify.c:4869
0x8ffb7d gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.c:10287
0x901be6 gimplify_stmt(tree_node**, gimple**)
../../gcc/gimplify.c:5688
0x8ff115 gimplify_and_add(tree_node*, gimple**)
../../gcc/gimplify.c:425
0x8ff115 gimplify_return_expr
../../gcc/gimplify.c:1359
0x8ff115 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.c:10536
0x901be6 gimplify_stmt(tree_node**, gimple**)
../../gcc/gimplify.c:5688
0x8ff7f3 gimplify_statement_list
../../gcc/gimplify.c:1537
0x8ff7f3 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
../../gcc/gimplify.c:10704
0x901be6 gimplify_stmt(tree_node**, gimple**)
../../gcc/gimplify.c:5688
0x909e8c gimplify_body(tree_node*, bool)
../../gcc/gimplify.c:11433
0x90a247 gimplify_function_tree(tree_node*)
../../gcc/gimplify.c:11589
0x7e20e7 cgraph_node::analyze()
../../gcc/cgraphunit.c:625
0x7e48af analyze_functions
../../gcc/cgraphunit.c:1086
0x7e515c symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.c:2542