3 ms·
This is very different and it seems a lot of people misunderstand this. Undefined behavior is not "data structure being corrupted". When data structures are co
by shp0ngle 5y ago
This is very different and it seems a lot of people misunderstand this.
Undefined behavior is not "data structure being corrupted". When data structures are corrupted, program still functions as written.
Undefined behavior is "things fly off the ceiling", no logic applies and programs start behaving essentially randomly because of the optimizations.
Undefined behavior is not broken data. That is still a well defined behavior.
- labawi 5y agoBehavior of a program after data (as in value) races can be defined and constrained. If you have wild pointer writes (aka arbitrary memory corruption) and almost any non-trivial control flow, the results are pretty much undefined. As in, it is pretty much impossible to specify or reason about what a program will do. The article: > ... such races can in turn lead to arbitrary memory corruption. Tearing writes themselves are not undefined behavior, but use them wrong and you're off into undefined territory, with no way back. > Undefined behavior is .. because of the optimizations. Optimizations are popular, but it doesn't matter why the behavior is undefined.