https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44677
--- Comment #29 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:35b19980046fc57d9d6851b8f4349bd22de3fa03 commit r16-2270-g35b19980046fc57d9d6851b8f4349bd22de3fa03 Author: Jason Merrill <ja...@redhat.com> Date: Mon Jul 14 18:29:17 2025 -0400 c++: don't mark void exprs as read [PR44677] In Jakub's patch for PR44677 he added code to prevent mark_exp_read on e.g. (void)++i from marking i as read, but it seems to me that we can generalize that to avoid looking any farther into any void expression; you can't read a void value, and an explicit cast will have already called mark_exp_read on its operand in convert_to_void. For testing I added an assert to catch places where we were trying to mark void expressions as read, and fix a few that it found. But there were several other places (such as check_return_expr) where we could have a void expression but always calling mark_exp_read makes sense, so I dropped the assert from the final commit. PR c++/44677 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_fold) [CLEANUP_POINT_EXPR]: Don't force rvalue. [COMPOUND_EXPR]: Likewise. * cvt.cc (convert_to_void): Call mark_exp_read later. * expr.cc (mark_use): Turn off read_p for any void argument. (mark_exp_read): Return early for void argument.