google / google/benchmark

bug and potential fix for using long double with DoNotOptimize and gcc

Open
#903 4 comments 0 reactions 1 assignee Claimed by @EricWF View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.