C++ Logo

sg12

Advanced search

Re: [ub] ub due to left operand of shift

From: John Regehr <regehr_at_[hidden]>
Date: Fri, 25 Oct 2013 14:09:41 -0600
I believe the arguments to shift are promoted separately, so this code
is still undefined when key[pos]>127.

John


> If I'm reading 5p10 correctly, this should help (and is consistently
> expressing intent):
>
> kappa[i] =
> (key[pos ] << 24u) ^
> (key[pos + 1] << 16u) ^
> (key[pos + 2] << 8u) ^
> (key[pos + 3] );
>
> Jens
> _______________________________________________
> ub mailing list
> ub_at_[hidden]
> http://www.open-std.org/mailman/listinfo/ub
>

Received on 2013-10-25 22:09:48