[C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)
Joseph Myers
joseph@codesourcery.com
Thu Jun 4 21:05:00 GMT 2015
On Wed, 3 Jun 2015, Marek Polacek wrote:
> > Well, ok then. This new version incorporates Richard S.'s suggestion,
> > and warns even for 1 << 31 in C99/C11 (also in C90 when -Wshift-overflow
> > is explicitely specified). For C++, it warns about 1 << 31 by default
> > only in C++11 mode, in C++14 never, otherwise only if -Wshift-overflow
> > is specified.
> >
> > But the fallout seems to be nonnegligible. So I think the default should
> > be -Wshift-overflow=1 that doesn't warn about 1 << 31, but still rejects
> > e.g. enum { A = 1 << 31 };. And -Wshift-overflow=2 would warn even about
> > 1 << 31. (Perhaps this is exactly what you had in mind, but I'm not sure.)
>
> Done in the following. I think this is the best approach. The documentation
> hopefully makes it clear what's the intended behavior.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
The C changes are OK.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc-patches
mailing list