4 ms·
Yeah, but they usually just say that the result is undefined. At least that's what C and C++ do. And it's useful for optimizers, because they can assume more ab
by thegeomaster 12y ago
Yeah, but they usually just say that the result is undefined. At least that's what C and C++ do. And it's useful for optimizers, because they can assume more about basic arithmetic in signed types and do some neat tricks.
- haberman 12y ago> Yeah, but they usually just say that the result is undefined. Just to clarify, I think you're talking about the INT_MIN / -1 case? I think that floating-point division by zero is defined in C and C++.
- thegeomaster 12y agoYes, I was talking about the signed integer overflow. Floating point division by zero is of course defined in C/C++, as per IEEE 754.
- logicallee 12y agoCalling it undefned is a cute meta-exception, but the compiler (or runtime) still does something when hitting that code.
- klodolph 12y agoYeah, the compiler typically assumes it works, and encodes assumptions that it does work into the surrounding code. On some systems you will get SIGFPE. On other systems, the result is something defined like 0. On some systems, the result is whatever happened to be in some register or whatever.
- pjmlp 12y ago> At least that's what C and C++ do. And it's useful for optimizers, And for security exploits.