4 ms·
I am 100% in agreement with the C standard committee on this one. Treating all use of uninitialized memory as undefined behavior is a reasonable limitation that
by mcherm 9y ago
I am 100% in agreement with the C standard committee on this one. Treating all use of uninitialized memory as undefined behavior is a reasonable limitation that gives compiler writers a great deal of flexibility to improve performance. If the only loss is the ability to use uninitialized memory as a source of entropy for random number generators, then that is an incredibly low price to pay for the increased performance.
- GedByrne 9y agoThen why isn't the code being disallowed? Why is it being silently removed in the middle of the night through an optimization back door?
- pornel 9y agoIt is disallowed by the standard. It's not disallowed by compilers, because they're deficient. In this case I'd guess compiler front-end doesn't track which values in an array are initialized, and when optimizing back-end sees UB it's too late to emit an error.
- vyodaiken 9y agoThey are improving performance in what way? My compiler: read input; emit nop, improves performance too.
- mcherm 9y agoIf your program ALSO compiles VALID programs correctly, and somehow those are faster because it replaces INVALID programs with a nop, that sounds great!