Open jcranmer-intel opened 7 months ago
@llvm/issue-subscribers-clang-frontend
Author: Joshua Cranmer (jcranmer-intel)
When compiled on an x86 system with
-m32 -mno-sse
, the correct result should be that the two lines both output2.22045e-16
, which icc is able to successfully do. However clang and gcc both report 0 for the first line and2.22045e-16
for the second: https://godbolt.org/z/4xGoaaoKP.
For GCC, you need an option either like -std=c17
or -fexcess-precision=standard
to tell it to conform to the ISO C standard. For instance, with -std=c17
, I get 2.22045e-16
on both lines, which is correct.
That said, I would regard the GCC behavior without -std=c17
or -fexcess-precision=standard
as a bug (similar to the one for constants).
On systems with FLT_EVAL_METHOD == 2 (i.e., x87-based floating-point computation), arithmetic expressions using
float
anddouble
should be evaluated usinglong double
instead. Clang isn't doing this:When compiled on an x86 system with
-m32 -mno-sse
, the correct result should be that the two lines both output2.22045e-16
, which icc is able to successfully do. However clang and gcc both report 0 for the first line and2.22045e-16
for the second: https://godbolt.org/z/4xGoaaoKP.(At first glance, this sounds exactly like https://github.com/llvm/llvm-project/issues/88956, but that is about constants and this is about constant expressions).
C99 section 6.6p5 says
C11 adds a footnote explicitly saying that
FLT_EVAL_METHOD
also applies to the translation environment, and C23 addsDEC_EVAL_METHOD
to the footnote, but otherwise the text remains the same in all versions of C.