Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The point is to push the info to the programmer so that the code can be re-written as only defined behavior. Yes this would eliminate the 'gains' of abusing UB, but it would actually fix the errors of abusing UB.


I guess signed indvars would be a prime example. Compilers famously ignore overflow of signed integers when computing loop trip counts.

Would it be better to only ever use unsigned integers for indvars and loop limits? Maybe. But that would reach deep into the types in stdlib for example.

And then there's https://software.intel.com/en-us/forums/intel-c-compiler/top...

So, all in all, not simple. Not that that invalidates your point: I just wanted to add some nuance.


The problem is the compiler cannot prove UB actually happens.

The point of these "use UB to optimize" approaches isn't to screw over simple programs with bugs. It's to better optimize larger, correct programs where higher levels of logic that the compiler is unaware of ensure UB never happens.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: