https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91993
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The sanitization boils down to adding COMPOUND_EXPRs with the checking in the first operand and whatever it would normally have in the second operand. using uc = unsigned char; auto foo (const uc &a, const uc &b, const uc &c) { return static_cast<uc>(static_cast<uc>(a << 1U) | b) | c; } auto bar (const uc &a, const uc &b, const uc &c, int &d) { return static_cast<uc>(static_cast<uc>((d++, a) << 1U) | b) | c; } warns in bar the same even with just -Wconversion and doesn't warn in foo. Now, I wonder if a way out of this wouldn't be in cp_build_binary_op to look through COMPOUND_EXPRs (say set some temporary to (not sure if op0 or orig_op0), and then while (TREE_CODE (op0) == COMPOUND_EXPR) op0 = TREE_OPERAND (op0, 1); and similarly for op1 (or orig_op1?) and then at the end readd the lhs's from the COMPOUND_EXPRs to the result (guess for doing_shift case and flag_strong_eval_order == 2 we'd need to either not do that or be extra careful, because in that case op0 is ordered before op1). Thoughts on this?