On Wed, 18 Nov 2015, Marek Polacek wrote: > diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c > index c18c307..48c1a98 100644 > --- gcc/c/c-typeck.c > +++ gcc/c/c-typeck.c > @@ -3512,7 +3512,11 @@ parser_build_binary_op (location_t location, enum > tree_code code, > code1, arg1.value, code2, arg2.value); > > if (warn_tautological_compare) > - warn_tautological_cmp (location, code, arg1.value, arg2.value); > + warn_tautological_cmp (location, code, > + /* This function will try to fold both > + args, so don't leak C_MAYBE_CONST_EXPR. */ > + remove_c_maybe_const_expr (arg1.value), > + remove_c_maybe_const_expr (arg2.value));
remove_c_maybe_const_expr doesn't seem to be quite what you want. Apart from this not being a case covered by the comment on the function, you're ignoring the possibility of the side effects in the C_MAYBE_CONST_EXPR_PRE. So I think you want something else: if either argument is a C_MAYBE_CONST_EXPR whose C_MAYBE_CONST_EXPR_PRE is non-NULL and has side-effects, don't run the comparison, and otherwise it's OK to go down to the C_MAYBE_CONST_EXPR_EXPR. -- Joseph S. Myers jos...@codesourcery.com