https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126066
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <[email protected]>: https://gcc.gnu.org/g:ec2b5122e1f52409f7207539cc821424fa209ad7 commit r17-2361-gec2b5122e1f52409f7207539cc821424fa209ad7 Author: Marek Polacek <[email protected]> Date: Tue Jul 7 16:52:39 2026 -0400 c++: ICE with requires and -Wsequence-point [PR126066] We trip on the assert in lvalue_kind/MODOP_EXPR whose comment says that we expect to see MODOP_EXPRs only during template processing. In this test we get there with processing_template_decl==0. The MODOP_EXPR is created in: /* Parse the requirement body. */ ++processing_template_decl; reqs = cp_parser_requirement_body (parser); --processing_template_decl; but we're not in a template when calling maybe_convert_cond which calls verify_sequence_points which ends up calling lvalue_p on the MODOP_EXPR. verify_sequence_points is walking the unevaluated operand of a requires because verify_tree assumes that all unknown expressions are evaluated, and REQUIRES_EXPR looks like a normal expression (tcc_expression). This patch changes REQUIRES_EXPR to tcc_exceptional. That means that the generic code (such as verify_tree) sees that it's magic and doesn't try to walk into it. PR c++/126066 gcc/c-family/ChangeLog: * c-common.cc (verify_tree): Add a comment. gcc/cp/ChangeLog: * constraint.cc (tsubst_requires_expr): Use REQUIRES_EXPR_LOCATION. (satisfaction_cache::get): Use cp_expr_location. (satisfaction_cache::save): Likewise. (finish_requires_expr): Use make_node and set REQUIRES_EXPR_*. * cp-objcp-common.cc (cp_tree_size): Handle REQUIRES_EXPR. (cp_common_init_ts): Change REQUIRES_EXPR from MARK_TS_EXP to MARK_TS_TYPED. * cp-tree.def (REQUIRES_EXPR): Make it tcc_exceptional with no operands. * cp-tree.h (struct tree_requires_expr): New. (REQUIRES_EXPR_PARMS): Adjust. (REQUIRES_EXPR_REQS): Likewise. (REQUIRES_EXPR_EXTRA_ARGS): Likewise. (REQUIRES_EXPR_LOCATION): New. (enum cp_tree_node_structure_enum): Add TS_CP_REQUIRES_EXPR. (union lang_tree_node): Add tree_requires_expr. (cp_expr_location): Handle REQUIRES_EXPR. * cxx-pretty-print.cc (pp_cxx_requires_expr): Use REQUIRES_EXPR_REQS. * decl.cc (cp_tree_node_structure): Handle REQUIRES_EXPR. * error.cc (print_requires_expression_info): Use REQUIRES_EXPR_PARMS. * mangle.cc (write_tparms_constraints): Use cp_expr_location. * module.cc (trees_out::core_vals): Handle REQUIRES_EXPR specially. (trees_in::core_vals): Likewise. * pt.cc (iterative_hash_template_arg): Handle REQUIRES_EXPR. * tree.cc (strip_typedefs_expr): Likewise. (cp_tree_equal): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-pr126066.C: New test. Reviewed-by: Jason Merrill <[email protected]>
