News for hackers. Stuff that matters.
Re:“What the Hardware Does” Is Not What Your Program Does: U... by saagarjha on Sunday July 14, 2019 @03:14PM (#20435309)
> So each time an uninitialized variable gets used, we can just use any machine register—and for different uses, those can be different registers! So, one time we “look” at x it can be at least 150, and then when we look at it again it is less than 120, even though x did not change. x was just uninitialized all the time.

Is this actually true? I thought these would just be poisoned and then the optimizer would just do whatever it liked in the presence of undefined behavior (like optimize the function to return true).

Re:“What the Hardware Does” Is Not What Your Program Does: U... by cperciva on Sunday July 14, 2019 @03:20PM (#20435355)
It could do that, but it doesn't have to. A common example is "a variable is set inside a loop and used outside it"; if the loop runs zero times, the variable will be used uninitialized, but the fastest compilation will assume that the loop runs at least once and read the value from whatever register/memory location the loop writes into.