https://bugs.kde.org/show_bug.cgi?id=442168

            Bug ID: 442168
           Summary: Floating-point erroneous behavior with memecheck with
                    regards to class (isfinite(), etc.)
           Product: valgrind
           Version: 3.15 SVN
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: memcheck
          Assignee: jsew...@acm.org
          Reporter: xavier.ro...@algolia.com
  Target Milestone: ---

Created attachment 141383
  --> https://bugs.kde.org/attachment.cgi?id=141383&action=edit
Minimal program demonstrating floating-point erroneous behavior with memcheck

SUMMARY

Floating-point erroneous behavior with memecheck with regards to class
(isfinite(), etc.), leading to consider -NaN as a finite number.


STEPS TO REPRODUCE
1. Compile the attached reproducible minimal case with clang-12 in at least O2
and -march=corei7-avx

clang-12 -std=c++20 -stdlib=libc++ -O2 -march=corei7-avx
isfinite-bug-with-clang12-O2-corei7-avx.cpp -lc++ -lm -o isfinite-bug

2. Run without valgrind

./isfinite-bug

3. Run with valgrind (valgrind --tool=memcheck)

valgrind --tool=memcheck ./isfinite-bug


OBSERVED RESULT

Run without valgrind: "All right" is emitted

Run with valgrind: "Error: expected 1 and got -nan" is emitted


EXPECTED RESULT

The valgrind version should always emit "All right"


SOFTWARE/OS VERSIONS
Linux, Ubuntu, 5.4.0-80-generic

ADDITIONAL INFORMATION
The issue is reproduced using valgrind-3.15.0

It requires:
* clang-12
* At least O2
* -march=corei7-avx

It is _not_ reproduced with an earlier version of clang (tested version:
clang-11), which hints of a recent special NaN/fp class optimization.

At this stage, I can not guarantee that this is a valgrind issue, or a
undefined-behavior-generated-code that happen to work without valgrind.

I'm available for any additional information.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to