https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95022
Bug ID: 95022 Summary: ICE: expected integer_cst, have call_expr Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: john at mcfarlane dot name Target Milestone: --- Doesn't occur with g++-9 but does happen with Ubuntu 20.04 GCC-10 and at head w. SHA a33649e6 Ubuntu 20.04 GCC-10: john@carbon:~/ws/gcc/build$ g++ --version g++ (Ubuntu 10-20200411-0ubuntu1) 10.0.1 20200411 (experimental) [master revision bb87d5cc77d:75961caccb7:f883c46b4877f637e0fa5025b4d6b5c9040ec566] Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Build from SHA a33649e6: john@carbon:~/ws/gcc/build$ ~/gcc-a33649e6/bin/g++ --version g++ (GCC) 11.0.0 20200509 (experimental) Copyright © 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The backtrace from the a33649e6 build is: - - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - john@carbon:~/ws/gcc/build$ ~/gcc-a33649e6/bin/g++ /home/john/ws/ubuntu-20.04/repro/source.cpp /home/john/ws/ubuntu-20.04/repro/source.cpp: In instantiation of ‘struct l<char>’: /home/john/ws/ubuntu-20.04/repro/source.cpp:13:56: required from ‘struct n<2, 2>’ /home/john/ws/ubuntu-20.04/repro/source.cpp:15:65: required by substitution of ‘template<int ar, int as, class al> decltype (n<ar, as>()) ap(al) [with int ar = 2; int as = 2; al = G]’ /home/john/ws/ubuntu-20.04/repro/source.cpp:24:22: required from here /home/john/ws/ubuntu-20.04/repro/source.cpp:11:42: internal compiler error: tree check: expected integer_cst, have call_expr in to_wide, at tree.h:5901 11 | auto m() -> decltype(decltype(aa<al>() >> g<h<>::c - 1>{}){}); | ~~~~~~~~~^~~~~~~~~~~~~~~~~~ 0x7df747 tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc/gcc/tree.c:9731 0x7df929 tree_check(tree_node const*, char const*, int, char const*, tree_code) ../../gcc/gcc/tree.h:3550 0x7df929 wi::to_wide(tree_node const*) ../../gcc/gcc/tree.h:5901 0x7e1ad8 wi::to_wide(tree_node const*) ../../gcc/gcc/tree.c:7407 0x7e1ad8 tree_int_cst_sgn(tree_node const*) ../../gcc/gcc/tree.c:7399 0xa90398 cp_build_binary_op(op_location_t const&, tree_code, tree_node*, tree_node*, int) ../../gcc/gcc/cp/typeck.c:5633 0x89c857 build_new_op_1 ../../gcc/gcc/cp/call.c:6524 0x89d1cd build_new_op(op_location_t const&, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) ../../gcc/gcc/cp/call.c:6570 0xa83603 build_x_binary_op(op_location_t const&, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) ../../gcc/gcc/cp/typeck.c:4268 0xa19a84 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:19438 0xa1f424 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.c:15913 0xa19ee8 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../gcc/gcc/cp/pt.c:20289 0xa1f424 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.c:15913 0xa299aa tsubst_function_type ../../gcc/gcc/cp/pt.c:14899 0xa1f020 tsubst(tree_node*, tree_node*, int, tree_node*) ../../gcc/gcc/cp/pt.c:15720 0xa2d84a tsubst_function_decl ../../gcc/gcc/cp/pt.c:13756 0xa1751f tsubst_decl ../../gcc/gcc/cp/pt.c:14197 0xa3a3db instantiate_class_template_1 ../../gcc/gcc/cp/pt.c:11798 0xa3b9f2 instantiate_class_template(tree_node*) ../../gcc/gcc/cp/pt.c:12106 0xa82039 complete_type(tree_node*) ../../gcc/gcc/cp/typeck.c:137 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. - - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - and the source.cpp input is: - - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - template <int a> struct b { static constexpr int c = a; }; template <typename d> auto aa() -> decltype(d()); template <int e> struct g { using f = __int128; constexpr operator f() { return e; } }; template <class = void> struct h; template <typename> struct k : b<8> {}; template <> struct h<> : k<char> {}; template <typename al> struct l { auto m() -> decltype(decltype(aa<al>() >> g<h<>::c - 1>{}){}); }; template <typename al, int, int> auto ao() -> decltype(l<al>()); template <int ar, int as> struct n { auto o() -> decltype(ao<char, ar, as>); }; template <int ar, int as = 2, class al> auto ap(al) -> decltype(n<ar, as>()); class G { public: G(); template <class al> constexpr G(al p) : ay(p) {} int ay; }; template <class = int> using az = G; auto i = az<>(g<7>{}); auto j = ap<2>(az<>{}) - - - - - - - - - - - - - - - >8 - - - - - - - - - - - - - - - The same code compiled with g++-9 john@carbon:~/ws/gcc/build$ g++-9 --version g++-9 (Ubuntu 9.3.0-10ubuntu2) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Does not produce an ICE but produces a diagnostic instead: john@carbon:~/ws/gcc/build$ g++-9 source.cpp /home/john/ws/ubuntu-20.04/repro/source.cpp: In instantiation of ‘struct n<2, 2>’: /home/john/ws/ubuntu-20.04/repro/source.cpp:15:65: required by substitution of ‘template<int ar, int as, class al> decltype (n<ar, as>()) ap(al) [with int ar = 2; int as = 2; al = G]’ /home/john/ws/ubuntu-20.04/repro/source.cpp:24:22: required from here /home/john/ws/ubuntu-20.04/repro/source.cpp:14:43: error: function returning a function 14 | template <int ar, int as> struct n { auto o() -> decltype(ao<char, ar, as>); }; | ^ /home/john/ws/ubuntu-20.04/repro/source.cpp:24:22: error: expected ‘,’ or ‘;’ at end of input 24 | auto j = ap<2>(az<>{}) | ^