From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41800 invoked by alias); 12 Aug 2015 17:10:35 -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 41788 invoked by uid 89); 12 Aug 2015 17:10:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.1 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 12 Aug 2015 17:10:35 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C33CC91DAF; Wed, 12 Aug 2015 17:10:33 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-104.phx2.redhat.com [10.3.113.104]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7CHAXkh030963; Wed, 12 Aug 2015 13:10:33 -0400 Subject: Re: [C/C++ PATCH] Fix -Wshift-overflow with sign bit To: Marek Polacek , GCC Patches , Jason Merrill , Joseph Myers References: <20150812153927.GK3335@redhat.com> From: Jeff Law Message-ID: <55CB7E08.1020607@redhat.com> Date: Wed, 12 Aug 2015 17:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20150812153927.GK3335@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00632.txt.bz2 On 08/12/2015 09:39 AM, Marek Polacek wrote: > This patch fixes a defect in -Wshift-overflow. We should only warn > about left-shifting 1 into the sign bit when -Wshift-overflow=2. But > this doesn't apply only for 1 << 31, but also for 2 << 30, etc. > In C++14, never warn about this. > > Neither existing tests nor documentation require updating, I think. > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > 2015-08-12 Marek Polacek > > PR c++/55095 > * c-common.c (maybe_warn_shift_overflow): Properly handle > left-shifting 1 into the sign bit. > > * c-c++-common/Wshift-overflow-6.c: New test. > * c-c++-common/Wshift-overflow-7.c: New test. > * g++.dg/cpp1y/left-shift-2.C: New test. I didn't realize C++14 fixed this bit of lameness. I'd read that it was under consideration when I was looking at Mikael's sext_hwi patch, but didn't follow up on the current status. OK for the trunk. jeff