From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74993 invoked by alias); 27 Sep 2016 12:42:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 74972 invoked by uid 89); 27 Sep 2016 12:42:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=shifting X-HELO: mail-oi0-f48.google.com Received: from mail-oi0-f48.google.com (HELO mail-oi0-f48.google.com) (209.85.218.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Sep 2016 12:42:40 +0000 Received: by mail-oi0-f48.google.com with SMTP id w11so13313461oia.2 for ; Tue, 27 Sep 2016 05:42:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=pV4F34H3W0mO6gAX5OgnHUj9luVTPUy7bau5btGQCkM=; b=R3WFPsxpGGDd6xK9ztzeBhkJcswPURdNn3kEktf89gX3hs7QtuKoBGr6PCenN/Fg9j vBNc7uzEDA8rRmUybY992n95Qidtmlxn2N14tHCybxp+Eq1NONaUXZqbzCSK3IB12Ov7 QEoeQxgD6cLk80WDKfRZ6kiTUYBSDcAZ/z2W2w4+v1fZh1C4RYs48ah1OJu7cJnaZ08c vwkHfSmzh4QV+GfnE0aK7JjXZWDv9Gr+ikX5JzLiLkzkpiA0g/TrG7Rol+UZ8UXE4Bb1 wzAzPelnfhKddt10c6YptJaUGgvZ6gr3JzezdRpvFSTmtypGyAFsUjgNm0+KlL9N4k6+ SaaA== X-Gm-Message-State: AE9vXwPmM1miTDGrsdZK4UsK+nw52zS0Xk0Z/83AtP7rD5F9wgsUjkXu0WiUIjSVq5A2RfnfTiKb+7hsCtRWJ7JE X-Received: by 10.202.216.139 with SMTP id p133mr34750976oig.83.1474980158732; Tue, 27 Sep 2016 05:42:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.105.167 with HTTP; Tue, 27 Sep 2016 05:42:18 -0700 (PDT) In-Reply-To: References: From: Jason Merrill Date: Tue, 27 Sep 2016 12:45:00 -0000 Message-ID: Subject: Re: [PATCH] Make -Wint-in-bool-context warn on suspicious shift ops To: Bernd Edlinger Cc: "gcc-patches@gcc.gnu.org" , Jeff Law Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg01962.txt.bz2 On Sun, Sep 25, 2016 at 3:46 AM, Bernd Edlinger 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? And why not warn for 0 << 0 and 1 << 0, which are just as pointless? Jason