[gcc r16-9275] c++: ICE with requires and -Wsequence-point [PR126066]

Marek Polacek via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:6d87c68f9904bab176c26359cdbb4a9001247cff

commit r16-9275-g6d87c68f9904bab176c26359cdbb4a9001247cff
Author: Marek Polacek <[email protected]>
Date:   Mon Jul 13 17:47:09 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).
    
    The trunk patch changed REQUIRES_EXPR to tcc_exceptional.  But in 16, we
    can just dial the assert down to _checking.
    
            PR c++/126066
    
    gcc/cp/ChangeLog:
    
            * tree.cc (lvalue_kind) <case MODOP_EXPR>: Use
            gcc_checking_assert instead of gcc_assert.
    
    Reviewed-by: Jason Merrill <[email protected]>

Diff:
---
 gcc/cp/tree.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 2bcbfa847079..1da3e7d6fc2a 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -280,7 +280,7 @@ lvalue_kind (const_tree ref)
     case MODOP_EXPR:
       /* We expect to see unlowered MODOP_EXPRs only during
 	 template processing.  */
-      gcc_assert (processing_template_decl);
+      gcc_checking_assert (processing_template_decl);
       if (CLASS_TYPE_P (TREE_TYPE (TREE_OPERAND (ref, 0))))
 	goto default_;
       else
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.