On Thu, 24 Aug 2017 18:21:15 -0700 "Keith Packard" <[email protected]> wrote:
> Michel Dänzer <[email protected]> writes: > > > Is assigning an unsigned value with the MSB set to a signed variable > > well-defined in C? > > I have no idea. And I just spent a few hours wading through the N1570 > draft of the C standard on a related issue. In particular, this is > worrying: > > 6.3.1.3 > > 3 Otherwise, the new type is signed and the value cannot be represented > in it; either the result is implementation-defined or an > implementation-defined signal is raised. > > I don't think the absence of a cast matters. > > Surely some better language lawyer can tell us the answer... Hi, why not just do what Alexander suggested and write the overflow tests such that they do not rely on uncertain behaviour? E.g. https://stackoverflow.com/questions/2633661/how-to-check-integer-overflow-in-c/2633929#2633929 No possibility for overflows, no sketchy casts. Thanks, pq
pgpy58FBWQyxm.pgp
Description: OpenPGP digital signature
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
