Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jan 2018 11:40:08 -0800
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        Warner Losh <imp@bsdimp.com>
Cc:        Dimitry Andric <dim@freebsd.org>, Eitan Adler <lists@eitanadler.com>, FreeBSD Hackers <freebsd-hackers@freebsd.org>, Ed Schouten <ed@nuxi.nl>
Subject:   Re: 1 << 31 redux
Message-ID:  <20180111194008.GA31206@troutmask.apl.washington.edu>
In-Reply-To: <CANCZdfqcmaW21K=SJz5yRbZE56njQNF6gYhLu17qMumggqA3Cw@mail.gmail.com>
References:  <CAF6rxg=GbfpBfPAAJg0RvpMrWW8p%2B0Ayf_Zd9i7Em2kOijFCjA@mail.gmail.com> <CABh_MKmy3ojYO3M6YwH2wWrEp5a4C-o2XC1icN%2BNj3GDo4f%2BZA@mail.gmail.com> <CA37BE71-935C-4349-AFEF-B98160460FFE@FreeBSD.org> <CANCZdfqcmaW21K=SJz5yRbZE56njQNF6gYhLu17qMumggqA3Cw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 11, 2018 at 08:47:16AM -0700, Warner Losh wrote:
> On Thu, Jan 11, 2018 at 6:37 AM, Dimitry Andric <dim@freebsd.org> wrote:
> 
> > On 11 Jan 2018, at 13:05, Ed Schouten <ed@nuxi.nl> wrote:
> > >
> > > 2018-01-11 13:03 GMT+01:00 Eitan Adler <lists@eitanadler.com>:
> > >> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180111194008.GA31206>