On Wed, Sep 18, 2013 at 03:10:42PM +0200, Marek Polacek wrote:
> --- gcc/cp/typeck.c.mp 2013-09-18 14:00:14.303869196 +0200
> +++ gcc/cp/typeck.c 2013-09-18 14:08:21.287770112 +0200
> @@ -4884,7 +4884,7 @@ cp_build_binary_op (location_t location,
> if (build_type == NULL_TREE)
> build_type = result_type;
>
> - if ((flag_sanitize & SANITIZE_UNDEFINED)
> + if ((flag_sanitize & SANITIZE_SHIFT || flag_sanitize & SANITIZE_DIVIDE)
I'd suggest to use
if ((flag & (SANITIZE_SHIFT | SANITIZE_DIVIDE))
instead.
> && !processing_template_decl
> && current_function_decl != 0
> && !lookup_attribute ("no_sanitize_undefined",
> @@ -4898,7 +4898,7 @@ cp_build_binary_op (location_t location,
> tf_none));
> op1 = maybe_constant_value (fold_non_dependent_expr_sfinae (op1,
> tf_none));
> - if (doing_div_or_mod)
> + if (doing_div_or_mod && flag_sanitize & SANITIZE_DIVIDE)
And, while the operator precedence is right, I think it would be better
to use if (doing_div_or_mod && (flag_sanitize & SANITIZE_DIVIDE))
Jakub