bug and potential fix for using long double with DoNotOptimize and gcc
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 1.8k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 8
Description
Hi,
1.) I discovered that g++ has a problem with +m inside DoNotOptimize.
As Jakub Jelinek stated in my gcc bugreport, +g works instead of +m (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92597).
2.) I attached the small example (test.cpp+makefile), which gives wrong values using g++[9.2] with +m.
Also, if you define -DFIX inside the makefile, gcc is working fine. Clang and Intel seem to not having this problem, but are also checked.
For reproduction, g++ is called to compile with +m:
$>make
...
FMA: 0; TYPE: double; ASM Volatile: 1 => y=6.9529e-305
FMA: 1; TYPE: long double; ASM Volatile: 1 => y=-nan
make: *** [makefile:17: diff_gcc] Error 1
If you uncomment the -DFIX inside the CFLAGS, gcc produces the correct numbers.
I don't know if this fixes the problem entirely, but I wanted to let you know that there is a problem and a workaround for gcc.
Cheers,
Klaus
[googlebench_bugreport.zip](https://github.com/google/benchmark/files/3874038/googlebench_bugreport.zip)
Contributor guide
Assessment
This issue has not been assessed yet.