https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106617
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
We don't fold because
case COMPOUND_EXPR:
/* When pedantic, a compound expression can be neither an lvalue
nor an integer constant expression. */
if (TREE_SIDE_EFFECTS (arg0) || TREE_CONSTANT (arg1))
return NULL_TREE;
/* Don't let (0, 0) be null pointer constant. */
tem = integer_zerop (arg1) ? build1_loc (loc, NOP_EXPR, type, arg1)
: fold_convert_loc (loc, type, arg1);
return tem;
where we chicken out because of the fear of early folding. At least the
C frontend should get this correct now. Ideally the above would
just return arg1 if !TREE_SIDE_EFFECTS (arg0). OTOH it's really sth for
language specific folding.
Of course the bug then would be still present when replacing (0, 0) with
something non-constant.