|
|
|
|
|
by CJefferson
393 days ago
|
|
I agree, I'd go further and say I wonder why primitive types aren't "frozen" by default. I totally understand not wanting to promise things get zeroed, but I don't really understand why full UB, instead of just "they have whatever value is initially in memory / the register / the compiler chose" is so much better. Has anyone ever done a performance comparison between UB and freezing I wonder? I can't find one. |
|
Also, an uninitialized value might be in a memory page that gets reclaimed and then mapped in again, in which case (because it hasn’t been written to) the OS doesn’t guarantee it will have the same value the second time. There was recently a bug discovered in one of the few algorithms that uses uninitialized values, because of this effect.