fork download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. class Foo {
  5. private:
  6. static constexpr const char* getId()
  7. {
  8. return __func__;
  9. }
  10.  
  11. public:
  12. static constexpr const char* id = Foo<T>::getId();
  13. };
  14.  
  15. template<typename T>
  16. constexpr const char* Foo<T>::id;
  17.  
  18.  
  19. int main()
  20. {
  21. std::cout << Foo<int>::id << std::endl;
  22. return 0;
  23. }
  24.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'constexpr const char* const Foo<int>::id':
prog.cpp:21:25:   required from here
prog.cpp:12:49:   in constexpr expansion of 'Foo<T>::getId<int>()'
prog.cpp:12:31: internal compiler error: Segmentation fault
  static constexpr const char* id = Foo<T>::getId();
                               ^
0x8699cca crash_signal
	../../src/gcc/toplev.c:383
0x848ea53 bool vec_safe_reserve<tree_node*, va_gc>(vec<tree_node*, va_gc, vl_embed>*&, unsigned int, bool)
	../../src/gcc/vec.h:575
0x848ea53 tree_node** vec_safe_push<tree_node*, va_gc>(vec<tree_node*, va_gc, vl_embed>*&, tree_node* const&)
	../../src/gcc/vec.h:669
0x848ea53 add_local_decl(function*, tree_node*)
	../../src/gcc/function.c:6702
0x86ebe88 remap_decls
	../../src/gcc/tree-inline.c:653
0x86ebf34 remap_block
	../../src/gcc/tree-inline.c:721
0x86ede63 copy_bind_expr
	../../src/gcc/tree-inline.c:794
0x86ede63 copy_tree_body_r(tree_node**, int*, void*)
	../../src/gcc/tree-inline.c:1128
0x887cecd walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hashset_traits>*))
	../../src/gcc/tree.c:11093
0x86eb116 copy_tree_body
	../../src/gcc/tree-inline.c:2965
0x86eb116 copy_fn(tree_node*, tree_node*&, tree_node*&)
	../../src/gcc/tree-inline.c:5987
0x82fa36d cxx_eval_call_expression
	../../src/gcc/cp/constexpr.c:1387
0x82f58be cxx_eval_constant_expression
	../../src/gcc/cp/constexpr.c:3127
0x82f7c8b cxx_eval_outermost_constant_expr
	../../src/gcc/cp/constexpr.c:3653
0x823566e store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int)
	../../src/gcc/cp/typeck2.c:833
0x81f8b8e check_initializer
	../../src/gcc/cp/decl.c:6011
0x820c027 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
	../../src/gcc/cp/decl.c:6623
0x821eb07 instantiate_decl(tree_node*, int, bool)
	../../src/gcc/cp/pt.c:20469
0x824c1a3 mark_used(tree_node*, int)
	../../src/gcc/cp/decl2.c:5032
0x824c53d mark_used(tree_node*)
	../../src/gcc/cp/decl2.c:5146
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-5/README.Bugs> for instructions.
stdout
Standard output is empty