llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.65k stars 11.84k forks source link

clang should support Annex F of ISO C (IEC 60559 / IEEE 754) #17379

Open vinc17fr opened 11 years ago

vinc17fr commented 11 years ago
Bugzilla Link 17005
Version unspecified
OS All
CC @delcypher,@sunfishcode,@seanm

Extended Description

clang should support Annex F of ISO C (IEC 60559 / IEEE 754), at least the basic features. Support could be controlled by options; for instance, it could be disabled by options like GCC's -ffast-math.

If clang intends to be a replacement for GCC (as its Wikipedia page says), this is really a must. GCC's IEEE 754 support is rather good, though not complete: http://gcc.gnu.org/wiki/FloatingPointMath

And clang should be at least as good as GCC. Currently clang doesn't even support basic features such as division by zero, which is regarded as undefined (as said in bug 17000).

llvmbot commented 10 years ago

The most visible issue caused by this is apparently that using -fsanitize=undefined on programs that make use of floating point division by 0.0 (which is perfectly legal udner IEEE floats) will print "runtime error: division by zero".

(Also see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=720935)

It's also scary to think that your program might run slightly incorrectly in corner cases under clang, while it's correct under gcc (at least with -std=c99, gcc intentionally breaks floating point semantics with -std=gnu99).

llvmbot commented 11 months ago

@llvm/issue-subscribers-c

Author: Vincent Lefèvre (vinc17fr)

| | | | --- | --- | | Bugzilla Link | [17005](https://llvm.org/bz17005) | | Version | unspecified | | OS | All | | CC | @delcypher,@sunfishcode,@seanm | ## Extended Description clang should support Annex F of ISO C (IEC 60559 / IEEE 754), at least the basic features. Support could be controlled by options; for instance, it could be disabled by options like GCC's -ffast-math. If clang intends to be a replacement for GCC (as its Wikipedia page says), this is really a must. GCC's IEEE 754 support is rather good, though not complete: http://gcc.gnu.org/wiki/FloatingPointMath And clang should be at least as good as GCC. Currently clang doesn't even support basic features such as division by zero, which is regarded as undefined (as said in bug 17000).