Hi, On Tue, 27 Sep 2016, Jason Merrill wrote:
> On Sun, Sep 25, 2016 at 3:46 AM, Bernd Edlinger > <bernd.edlin...@hotmail.de> wrote: > > This patch makes -Wint-in-bool-context warn on suspicious integer left > > shifts, when the integer is signed, which is most likely some kind of > > programming error, for instance using "<<" instead of "<". > > > > The warning is motivated by the fact, that an overflow on integer shift > > left is undefined behavior, even if gcc won't optimize the shift based > > on the undefined behavior. > > > > So in absence of undefined behavior the boolean result does not depend > > on the shift value, thus the whole shifting is pointless. > > It's pointless for unsigned integers, too; why not warn for them as > well? Um, because left shift on unsigned integers is never undefined, so !!(1u << a) is meaningful and effectively tests if a < CHAR_BITS*sizeof(unsigned) ? Ciao, Michael.