Use unsigned(-1) for lshift

Joseph S. Myers joseph@codesourcery.com
Fri May 24 15:08:00 GMT 2013


On Fri, 24 May 2013, Richard Biener wrote:

> On Thu, May 23, 2013 at 9:47 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> > Hello,
> >
> > this is a simple patch to reduce a bit the noise in PR57324 (undefined
> > behavior flagged by clang). I only handled some of the most obvious ones.
> > Passes bootstrap+testsuite on x86_64-linux-gnu.
> 
> Hm, so ISO C99 says in 6.5.7/4 that (E1 << E2) "If E1 has signed type
> and nonnegative
> value, and E1 * 2^E2 is representable in the result type, then that is the
> resulting value; otherwise, the behavior is undefined."
> 
> While seriously underspecified for signed negative values (always undefined?!
> or well-defined?!), I wonder why CLang requires

Always undefined for signed negative values (compared to the 
implementation-defined of C90; DR#081).

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list