4 ms·
You are looking for a version of C that traps on undefined behavior–which is totally fine!–but do know that this would either be something that does not optimiz
by saagarjha 7y ago
You are looking for a version of C that traps on undefined behavior–which is totally fine!–but do know that this would either be something that does not optimize code and/or contains runtime security checks for things that C traditionally does not have checks for.
- lmm 7y agoTrapping implementations have a long and honourable history on platforms where the hardware supports it. Ironically, the whole reason most undefined behaviour is undefined is to permit trapping implementations - implementations that do something safer than just continuing with an implementation-defined value - but instead modern compilers treat it as a license to do something even more dangerous.
- saagarjha 7y agoThankfully, modern compilers have begun inserting traps much more often upon running into undefined behavior.