From owner-freebsd-hackers@freebsd.org Thu Jan 11 15:47:19 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 78A5BE6AA82 for ; Thu, 11 Jan 2018 15:47:19 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 298EF7708A for ; Thu, 11 Jan 2018 15:47:19 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-wm0-x235.google.com with SMTP id g75so6503993wme.0 for ; Thu, 11 Jan 2018 07:47:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=qCBfBU59UaIFQBbe+WuoBGiMUSDCFuKDQatC0/PchzI=; b=zu3jvljphBs32YbK2cIUQOcXTYmVfRaIe8zWI1XRgSCJ7wb2jurrjHxJ5PeUUuUQRM pOznOvbGI2bBkiQBuLhwKveEh/XA20F4yfLZ7CLQJLAQcCC9wPBADIRIDgjTW8Gh6YGp CAUfY5w+dmcXfjnifIWB1vCfmFw0vZb4wdbIJQeU7Km9vjaVM+YUnSb1l0BAVwvQofkB ZeOu67NCnnkomNIpRY1EhIOrflmjr85rcfU8PQGjpV54JtVY6y0Tz31CsrDJVYAtDOBh L32gc/InYDP3J+e4G08ZwVjC2ptgj0XuzueUlAvqbOrlfT4yDMVzeAnZq5J1AGcIi8+1 A4Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=qCBfBU59UaIFQBbe+WuoBGiMUSDCFuKDQatC0/PchzI=; b=cDbuQMKurmyS/XYdPxT1k2Y4Vr5clqSpQSaC4xbTqDkqdif1AsvCcKV/9xolkQDH9C YtDl6uyuLT78/8Lu4q4rSRRVTk0YPxBmwOTRXA5NdyKKiQTl2mNPgWAa3tiseR3tu8Qi FhfIcnkHuLCyW+KTLUh0jnMYrdaYYSS1/iFfH4GZiA0FN99iW205rfjZcv9+aTQKHThH mzwvLEx1zOL86PT6O1I42xaR0M7vNguLooSPHc394jRHZrYIAUhe4ZfVQi8mcmR92lPM hqZp1AkYk3XxTZnap7Q7WC4Rqje4ezJAGCTEyyi9v5gzPzGu7SzWSjfNPXkDNgPDbLGR pZnQ== X-Gm-Message-State: AKGB3mL6MwdtJ9A0r2z4K2VMTdL9PaotosZn1EOft3HG76bV4sLF41cz gkuDwbtd9roV3AIizAbf9ieyY54j29g+ZFz3+R+I0Q== X-Google-Smtp-Source: ACJfBovSWblF60zsC8B7Xac00xfGpe+dpxMsiQFCNL8ZXnIa8d2ooKo9GA7NE2dRrcvf5GbVcTKTAQl+YsQwd2olIuE= X-Received: by 10.80.147.228 with SMTP id o91mr31682168eda.206.1515685637007; Thu, 11 Jan 2018 07:47:17 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.80.195.88 with HTTP; Thu, 11 Jan 2018 07:47:16 -0800 (PST) X-Originating-IP: [50.253.99.174] In-Reply-To: References: From: Warner Losh Date: Thu, 11 Jan 2018 08:47:16 -0700 X-Google-Sender-Auth: 27ekSWxqbT0FUpoKC55fytml3-s Message-ID: Subject: Re: 1 << 31 redux To: Dimitry Andric Cc: Ed Schouten , Eitan Adler , FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jan 2018 15:47:19 -0000 On Thu, Jan 11, 2018 at 6:37 AM, Dimitry Andric wrote: > On 11 Jan 2018, at 13:05, Ed Schouten wrote: > > > > 2018-01-11 13:03 GMT+01:00 Eitan Adler : > >> I'd also like to see if we could find some more general solution, be it > a > >> compiler warning, bit set macro, or otherwise. > > > > Does Clang already offer a warning for this? If so, we should consider > > adding it to WARNS=6. > > There is a -Wshift-sign-overflow flag, but it isn't enabled by default: > > $ clang -Wshift-sign-overflow -c bar.c > bar.c:1:26: warning: signed shift result (0x80000000) sets the sign bit of > the shift expression's type ('int') and becomes negative > [-Wshift-sign-overflow] > int bar(void) { return 1 << 31; } > ~ ^ ~~ > > I would expect quite a lot of stuff to break if you enable it, though. :) > > And of course, there is -fsanitize=undefined, which can catch this kind > of thing at runtime. > If we can't get people to fix the warnings we have in the tree now (especially the kernel), why enable new warnings that will just be ignored? Warner