From owner-freebsd-hackers@freebsd.org Thu Jan 11 19:40:18 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 A8C55E7800B for ; Thu, 11 Jan 2018 19:40:18 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 8974D823AE; Thu, 11 Jan 2018 19:40:18 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id w0BJe9eD032394 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 11 Jan 2018 11:40:09 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id w0BJe8HQ032380; Thu, 11 Jan 2018 11:40:08 -0800 (PST) (envelope-from sgk) Date: Thu, 11 Jan 2018 11:40:08 -0800 From: Steve Kargl To: Warner Losh Cc: Dimitry Andric , Eitan Adler , FreeBSD Hackers , Ed Schouten Subject: Re: 1 << 31 redux Message-ID: <20180111194008.GA31206@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) 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 19:40:18 -0000 On Thu, Jan 11, 2018 at 08:47:16AM -0700, Warner Losh wrote: > 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? Create WARNS=7 with -Werror added to command line option. Edit the various *.mk files to force WARNS=7 Watch warnings get fixed. -- Steve