https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108503
Bug ID: 108503 Summary: [13 Regression] ICE in get_array_or_vector_nelts, at cp/constexpr.cc:4119 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gs...@t-online.de Target Milestone: --- Started between 20221127 and 20221204 : $ cat z1.cc namespace std { template<typename T> struct tuple_size; template<int, typename> struct tuple_element; } struct A { template <int I> int& get() { return 1; } }; template<> struct std::tuple_size<A> { static const int value = 3; }; template<int I> struct std::tuple_element<I,A> { using type = int; }; struct B { A *begin(); A *end(); }; void f (B a) { #pragma omp for collapse(2) for (auto [i, j, k] : a) for (int l = i; l < j; l += k) ; } $ g++-13-20230122 -c z1.cc -fopenmp -Wall z1.cc: In member function 'int& A::get()': z1.cc:6:40: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int' 6 | template <int I> int& get() { return 1; } | ^ z1.cc: In function 'void f(B)': z1.cc:18:25: internal compiler error: in get_array_or_vector_nelts, at cp/constexpr.cc:4119 18 | for (int l = i; l < j; l += k) | ^ 0x88770e get_array_or_vector_nelts ../../gcc/cp/constexpr.cc:4119 0x887804 eval_and_check_array_index ../../gcc/cp/constexpr.cc:4171 0x88b5e9 cxx_eval_array_reference ../../gcc/cp/constexpr.cc:4208 0x8826ed cxx_eval_constant_expression ../../gcc/cp/constexpr.cc:7516 0x880e9a cxx_eval_constant_expression ../../gcc/cp/constexpr.cc:7042 0x8837ac cxx_eval_indirect_ref ../../gcc/cp/constexpr.cc:5642 0x8837ac cxx_eval_constant_expression ../../gcc/cp/constexpr.cc:7358 0x88d3ba cxx_eval_outermost_constant_expr ../../gcc/cp/constexpr.cc:8252 0x892882 maybe_constant_value(tree_node*, tree_node*, bool) ../../gcc/cp/constexpr.cc:8527 0x956053 fold_for_warn(tree_node*) ../../gcc/cp/expr.cc:421 0xc1d801 warn_tautological_cmp(op_location_t const&, tree_code, tree_node*, tree_node*) ../../gcc/c-family/c-warn.cc:485 0x84369b build_new_op(op_location_t const&, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node*, tree_node**, int) ../../gcc/cp/call.cc:7354 0xb485cd build_x_binary_op(op_location_t const&, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node*, tree_node**, int) ../../gcc/cp/typeck.cc:4722 0xa1c40f cp_parser_omp_for_cond ../../gcc/cp/parser.cc:42701 0xa1c40f cp_parser_omp_for_loop ../../gcc/cp/parser.cc:43652 0xa410f6 cp_parser_omp_for ../../gcc/cp/parser.cc:44005 0xa56f14 cp_parser_omp_construct ../../gcc/cp/parser.cc:48527 0xa20a7f cp_parser_pragma ../../gcc/cp/parser.cc:49207 0xa2740c cp_parser_statement ../../gcc/cp/parser.cc:12434 0xa28884 cp_parser_statement_seq_opt ../../gcc/cp/parser.cc:12909