back

by uecker·3y ago·view on hn ↗
I fully agree with this. For example that assigning a freed pointer in C is UB is not because of optimization, but because there were real world architectures with memory segmentation were loading such a pointer caused a run-time trap (e.g. 286 protected mode). Or that reading an uninitialized automatic variable is UB is because it could cause a trap on architectures which could detect this (e.g. IA-64). There were also C versions with bounds checking etc. That compilers which are popular today focus on exploiting UB for optimization instead of security is an implementation choice, but not a fundamental problem of the language itself.