[PATCH] Make -Wint-in-bool-context warn on suspicious shift ops

Jason Merrill jason@redhat.com
Thu Sep 29 20:53:00 GMT 2016


On Thu, Sep 29, 2016 at 3:58 PM, Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
> Unfortunately, without that exception there is a false positive:
>
> In file included from ../../gcc-trunk/gcc/ada/gcc-interface/decl.c:30:0:
> ../../gcc-trunk/gcc/ada/gcc-interface/decl.c: In function 'int
> adjust_packed(tree, tree, int)':
> ../../gcc-trunk/gcc/tree.h:1874:22: error: << on signed integer in
> boolean context [-Werror=int-in-bool-context]
>        ? ((unsigned)1) << ((NODE)->type_common.align - 1) : 0)
>          ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Ah, this issue again: the shift isn't in boolean context, it's in
integer context.  I think we want to be a lot more conservative about
these warnings in the arms of a COND_EXPR.  In fact, I think the
entire

      /* Distribute the conversion into the arms of a COND_EXPR.  */

section is wrong now that we're doing delayed folding.

Jason



More information about the Gcc-patches mailing list