Re: Loops depending on undefined behavior

2016-01-26 Thread Todd C. Miller
On Mon, 25 Jan 2016 22:20:53 -0500, Michael McConville wrote: > The third case seems questionable. However, (IIUC) integer conversion > rules dictate that the int is implicitly cast to an unsigned int[1] and > that two's complement arithmetic is preserved in this cast.[2] > > C integer type rules

Loops depending on undefined behavior

2016-01-25 Thread Michael McConville
I've discussed the below with otto@, who thought it was sound but wanted confirmation before I commit. While debugging rarpd(8) for unrelated reasons, I noticed a loop of the following form: > for (i = 1; i; i <<= 1) where i is an int. This relies on shifting into and then out of the sign bit,