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

> Why can't there be a different option to emit a compiler error whenever -fsanitize=undefined would cause the compiler to add program-crashing code?

The simple answer is "the halting problem".

If you can build a compiler that knows with certainty what runtime behavior would result from any program (including whether undefined behavior occurs), then you could solve the halting problem, but the halting problem is provably undecidable. So such a compiler cannot exist even in theory for the general case.

Yes, you can template-match a bunch of special cases, but the user can always write new code that doesn't match any of your "known to be defined behavior" patterns but still executes only defined behavior. Guaranteed!



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

Search: