Re:Where do Google's flaky tests come from?
by P_I_Staker on Saturday February 02, 2019 @12:27AM
(#19061297)
It may be fun to point out that the complier could technically launch a game of Tetris or rm -rf /, but is that what any mainstream compiler does? I guess the behavior could be inconsistent, but who'd design a compiler like that? Seems like it'll roll over or it won't (ie. stay stuck at INT_MAX). Good unit tests would catch this if you changed compiler, but really you should handle it explicitly (look before you leap).
Re:Where do Google's flaky tests come from?
by voidmain on Saturday February 02, 2019 @08:42AM
(#19062915)
Not at all. In a code path where the compiler reasons that x is definitely INT_MAX, it could simply omit this code, leaving y uninitialized and nondeterministic.
Re:Where do Google's flaky tests come from?
by andrewprock on Saturday February 02, 2019 @12:32AM
(#19061311)
It will act consistently if the value of x is consistent. If it's not, then it could flake out on that line.
Re:Where do Google's flaky tests come from?
by joshuamorton on Saturday February 02, 2019 @12:34AM
(#19061319)
If the value of x is inconsistent, you had flakyness somewhere else.
That line will always act consistently, modulo solar radiation.
That's not true in a theoretical sense (undefined behavior allows me to rewrite signed overflow to "return 7 with some probability, and `rm ~/` otherwise"), but for any modern compiler, I'd assume that the optimizations chosen where signed overflow is undefined don't involve randomness.