[llvm-commits] [PATCH] Fix various instances of undefined behavior

Stephen Canon scanon at apple.com
Thu Oct 13 19:06:21 PDT 2011


On Oct 13, 2011, at 1:59 AM, Ahmed Charles wrote:

> That is true, though the C++ standard doesn't require IEEE 754 (aka
> IEC 559), though it does place requirements on implementations which
> choose to use IEEE 754, but one of those doesn't seem to be whether
> division by zero is undefined.

At least for C, if an implementation that conforms to Annex F (IEC 60559 floating-point arithmetic) , then division is fully defined (F.3 Operators and functions):

	• "The +, −, *, and / operators provide the IEC 60559 add, subtract, multiply, and divide operations."

I'm not on a machine with a copy of the C++ standard at the moment, but it has similar language.  Even if it didn't, you can't "use IEEE 754" while leaving division by zero undefined.  Arithmetic completion is the most important (and most often overlooked) feature of that standard.

- Steve



More information about the llvm-commits mailing list