https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70344
Bug ID: 70344 Summary: ICE on valid code at -O1 and above on x86_64-linux-gnu in adjust_temp_type, at cp/constexpr.c:1078 Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- The following code causes an ICE when compiled with the current GCC trunk on x86_64-linux-gnu at -O1 and above in both 32-bit and 64-bit modes. This is a regression from 5.3.x. $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 6.0.0 20160321 (experimental) [trunk revision 234361] (GCC) $ $ g++-trunk -O0 -std=c++11 -c small.cpp $ g++-5.3 -O1 -std=c++11 -c small.cpp $ $ g++-trunk -O1 -std=c++11 -c small.cpp small.cpp: In instantiation of ‘constexpr int fn(T) [with T = Z]’: small.cpp:15:18: required from here small.cpp:13:1: internal compiler error: in adjust_temp_type, at cp/constexpr.c:1078 } ^ 0x84505a adjust_temp_type ../../gcc-source-trunk/gcc/cp/constexpr.c:1078 0x84bbfb cxx_bind_parameters_in_call ../../gcc-source-trunk/gcc/cp/constexpr.c:1128 0x84bbfb cxx_eval_call_expression ../../gcc-source-trunk/gcc/cp/constexpr.c:1312 0x84d57b cxx_eval_constant_expression ../../gcc-source-trunk/gcc/cp/constexpr.c:3381 0x853a19 cxx_eval_outermost_constant_expr ../../gcc-source-trunk/gcc/cp/constexpr.c:3946 0x85671c maybe_constant_value_1 ../../gcc-source-trunk/gcc/cp/constexpr.c:4134 0x85671c maybe_constant_value(tree_node*, tree_node*) ../../gcc-source-trunk/gcc/cp/constexpr.c:4155 0x830a9f cp_fold ../../gcc-source-trunk/gcc/cp/cp-gimplify.c:2188 0x830816 cp_fold_rvalue ../../gcc-source-trunk/gcc/cp/cp-gimplify.c:1887 0x830816 cp_fold ../../gcc-source-trunk/gcc/cp/cp-gimplify.c:2072 0x83135e cp_fold_r ../../gcc-source-trunk/gcc/cp/cp-gimplify.c:944 0x1009b64 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, default_hash_traits<tree_node*> >*)) ../../gcc-source-trunk/gcc/tree.c:11531 0x65701f finish_function(int) ../../gcc-source-trunk/gcc/cp/decl.c:14688 0x67b622 instantiate_decl(tree_node*, int, bool) ../../gcc-source-trunk/gcc/cp/pt.c:22029 0x7098ea mark_used(tree_node*, int) ../../gcc-source-trunk/gcc/cp/decl2.c:5279 0x612481 build_over_call ../../gcc-source-trunk/gcc/cp/call.c:7706 0x621b3f build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, int) ../../gcc-source-trunk/gcc/cp/call.c:4152 0x7bc4a1 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) ../../gcc-source-trunk/gcc/cp/semantics.c:2461 0x736799 cp_parser_postfix_expression ../../gcc-source-trunk/gcc/cp/parser.c:6904 0x73fb0c cp_parser_unary_expression ../../gcc-source-trunk/gcc/cp/parser.c:7988 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ --------------------------------- struct Z { Z () = default; Z (Z const &) = default; constexpr Z (Z &&) {} }; template < typename T > constexpr int fn (T v) { return fn (v); } auto t = fn (Z ());