https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63996

            Bug ID: 63996
           Summary: Infinite loop in invalid C++14 constexpr fn
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org

constexpr int
foo (int i)
{
  int a[i] = { };
}

constexpr int j = foo (1);

$ ./cc1plus -quiet bug.C -std=c++14
bug.C:7:23:   in constexpr expansion of ‘foo(1)’
bug.C:7:25: error: ‘(int*)(& a)’ is not a constant expression
 constexpr int j = foo (1);
                         ^
^C

$ gstack 13911
#0  initializer_constant_valid_p_1 (value=0x7f1d3b348b40,
endtype=0x7f1d3b35a000, cache=0x0) at /home/marek/src/gcc/gcc/varasm.c:4525
#1  0x00000000011b7d7e in initializer_constant_valid_p (value=0x7f1d3b348b40,
endtype=0x7f1d3b35a000) at /home/marek/src/gcc/gcc/varasm.c:4543
#2  0x00000000008c2178 in reduced_constant_expression_p (t=0x7f1d3b348b40) at
/home/marek/src/gcc/gcc/cp/constexpr.c:1431
#3  0x00000000008c76f9 in cxx_eval_constant_expression (ctx=0x7fffbdeb8ac0,
t=0x7f1d3b348b40, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x7fffbdeb8a38) at
/home/marek/src/gcc/gcc/cp/constexpr.c:2820
#4  0x00000000008c7302 in cxx_eval_statement_list (ctx=0x7fffbdeb8ac0,
t=0x7f1d3b49d560, non_constant_p=0x7fffbdeb945f, overflow_p=0x7fffbdeb945e,
jump_target=0x7fffbdeb8a38) at /home/marek/src/gcc/gcc/cp/constexpr.c:2734
#5  0x00000000008c7432 in cxx_eval_loop_expr (ctx=0x7fffbdeb8ac0,
t=0x7f1d3b49d700, non_constant_p=0x7fffbdeb945f, overflow_p=0x7fffbdeb945e,
jump_target=0x7fffbdeb8a38) at /home/marek/src/gcc/gcc/cp/constexpr.c:2761
#6  0x00000000008c944b in cxx_eval_constant_expression (ctx=0x7fffbdeb8ac0,
t=0x7f1d3b49d700, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x7fffbdeb8a38) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3308
#7  0x00000000008c7302 in cxx_eval_statement_list (ctx=0x7fffbdeb8ac0,
t=0x7f1d3b496fe0, non_constant_p=0x7fffbdeb945f, overflow_p=0x7fffbdeb945e,
jump_target=0x7fffbdeb8a38) at /home/marek/src/gcc/gcc/cp/constexpr.c:2734
#8  0x00000000008c8fec in cxx_eval_constant_expression (ctx=0x7fffbdeb8ff0,
t=0x7f1d3b496fe0, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x0) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3242
#9  0x00000000008c8bb4 in cxx_eval_constant_expression (ctx=0x7fffbdeb8ff0,
t=0x7f1d3b49d540, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x0) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3207
#10 0x00000000008c8bb4 in cxx_eval_constant_expression (ctx=0x7fffbdeb8ff0,
t=0x7f1d3b49d520, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x7fffbdeb9220) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3207
#11 0x00000000008c8393 in cxx_eval_constant_expression (ctx=0x7fffbdeb8ff0,
t=0x7f1d3b49d500, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x7fffbdeb9220) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3002
#12 0x00000000008c8393 in cxx_eval_constant_expression (ctx=0x7fffbdeb8ff0,
t=0x7f1d3b49d4e0, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x7fffbdeb9220) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3002
#13 0x00000000008c7302 in cxx_eval_statement_list (ctx=0x7fffbdeb8ff0,
t=0x7f1d3b496ea0, non_constant_p=0x7fffbdeb945f, overflow_p=0x7fffbdeb945e,
jump_target=0x7fffbdeb9220) at /home/marek/src/gcc/gcc/cp/constexpr.c:2734
#14 0x00000000008c8fec in cxx_eval_constant_expression (ctx=0x7fffbdeb93f0,
t=0x7f1d3b496ea0, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x7fffbdeb9220) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3242
#15 0x00000000008c906b in cxx_eval_constant_expression (ctx=0x7fffbdeb93f0,
t=0x7f1d3b348ab0, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x7fffbdeb9220) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3248
#16 0x00000000008c1bfd in cxx_eval_call_expression (ctx=0x7fffbdeb93f0,
t=0x7f1d3b3400a8, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e) at /home/marek/src/gcc/gcc/cp/constexpr.c:1350
#17 0x00000000008c7afa in cxx_eval_constant_expression (ctx=0x7fffbdeb93f0,
t=0x7f1d3b3400a8, addr=false, non_constant_p=0x7fffbdeb945f,
overflow_p=0x7fffbdeb945e, jump_target=0x0) at
/home/marek/src/gcc/gcc/cp/constexpr.c:2892
#18 0x00000000008c980f in cxx_eval_outermost_constant_expr (t=0x7f1d3b3400a8,
allow_non_constant=false, strict=true, object=0x7f1d3b341ea0) at
/home/marek/src/gcc/gcc/cp/constexpr.c:3374
#19 0x00000000008c9e76 in cxx_constant_value (t=0x7f1d3b3400a8,
decl=0x7f1d3b341ea0) at /home/marek/src/gcc/gcc/cp/constexpr.c:3462
#20 0x000000000071df40 in store_init_value (decl=0x7f1d3b341ea0,
init=0x7f1d3b3400a8, cleanups=0x7fffbdeb95d0, flags=5) at
/home/marek/src/gcc/gcc/cp/typeck2.c:809
#21 0x0000000000675df3 in check_initializer (decl=0x7f1d3b341ea0,
init=0x7f1d3b3400a8, flags=5, cleanups=0x7fffbdeb95d0) at
/home/marek/src/gcc/gcc/cp/decl.c:5909
#22 0x0000000000678e32 in cp_finish_decl (decl=0x7f1d3b341ea0,
init=0x7f1d3b3400a8, init_const_expr_p=true, asmspec_tree=0x0, flags=5) at
/home/marek/src/gcc/gcc/cp/decl.c:6535
#23 0x000000000079d0e7 in cp_parser_init_declarator (parser=0x7f1d3b499000,
decl_specifiers=0x7fffbdeb9790, checks=0x0, function_definition_allowed_p=true,
member_p=false, declares_class_or_enum=0, function_definition_p=0x7fffbdeb981b,
maybe_range_for_decl=0x0) at /home/marek/src/gcc/gcc/cp/parser.c:17188
#24 0x0000000000793e6f in cp_parser_simple_declaration (parser=0x7f1d3b499000,
function_definition_allowed_p=true, maybe_range_for_decl=0x0) at
/home/marek/src/gcc/gcc/cp/parser.c:11522
#25 0x0000000000793c5f in cp_parser_block_declaration (parser=0x7f1d3b499000,
statement_p=false) at /home/marek/src/gcc/gcc/cp/parser.c:11403
#26 0x00000000007939e3 in cp_parser_declaration (parser=0x7f1d3b499000) at
/home/marek/src/gcc/gcc/cp/parser.c:11300
#27 0x0000000000793590 in cp_parser_declaration_seq_opt (parser=0x7f1d3b499000)
at /home/marek/src/gcc/gcc/cp/parser.c:11186
#28 0x0000000000786ff6 in cp_parser_translation_unit (parser=0x7f1d3b499000) at
/home/marek/src/gcc/gcc/cp/parser.c:4101
#29 0x00000000007bc8db in c_parse_file () at
/home/marek/src/gcc/gcc/cp/parser.c:32197
#30 0x0000000000922103 in c_common_parse_file () at
/home/marek/src/gcc/gcc/c-family/c-opts.c:1039
#31 0x0000000000e9fe93 in compile_file () at
/home/marek/src/gcc/gcc/toplev.c:570
#32 0x0000000000ea22e6 in do_compile () at
/home/marek/src/gcc/gcc/toplev.c:2041
#33 0x0000000000ea24f0 in toplev::main (this=0x7fffbdeb9a4f, argc=4,
argv=0x7fffbdeb9b48) at /home/marek/src/gcc/gcc/toplev.c:2138
#34 0x0000000000634669 in main (argc=4, argv=0x7fffbdeb9b48) at
/home/marek/src/gcc/gcc/main.c:38

Reply via email to