[PATCH] Fix condition in is_aligning_offset (PR c/61271)

Richard Biener richard.guenther@gmail.com
Tue Aug 26 08:04:00 GMT 2014


On Thu, Aug 21, 2014 at 5:52 PM, Marek Polacek <polacek@redhat.com> wrote:
> This is one of the issues that -Wlogical-not-parentheses detected.
> Interestingly, this code has been added in 2002 (!).  I believe the
> logical not there should be just removed; the comment above it says
>   /* We must now have a BIT_AND_EXPR with a constant that is one less than
>      power of 2 and which is larger than BIGGEST_ALIGNMENT.  */
> so if the constant is not one less than power of 2 (exact_log2 returns -1),
> we should bail out.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

Ok.

> Should I backport this to 4.9/4.8 after a while?

Yes please.

Thanks,
Richard.

> 2014-08-21  Marek Polacek  <polacek@redhat.com>
>
>         PR c/61271
>         * expr.c (is_aligning_offset): Remove logical not.
>
> diff --git gcc/expr.c gcc/expr.c
> index 920d47b..05d81dc 100644
> --- gcc/expr.c
> +++ gcc/expr.c
> @@ -10721,7 +10721,7 @@ is_aligning_offset (const_tree offset, const_tree exp)
>        || !tree_fits_uhwi_p (TREE_OPERAND (offset, 1))
>        || compare_tree_int (TREE_OPERAND (offset, 1),
>                            BIGGEST_ALIGNMENT / BITS_PER_UNIT) <= 0
> -      || !exact_log2 (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1) < 0)
> +      || exact_log2 (tree_to_uhwi (TREE_OPERAND (offset, 1)) + 1) < 0)
>      return 0;
>
>    /* Look at the first operand of BIT_AND_EXPR and strip any conversion.
>
>         Marek



More information about the Gcc-patches mailing list