[ub] ub due to left operand of shift

John Regehr regehr at cs.utah.edu
Fri Oct 25 22:09:41 CEST 2013


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 isocpp.open-std.org
> http://www.open-std.org/mailman/listinfo/ub
>


More information about the ub mailing list