Bug 491940 - ldexpf() does not set OF flag when running in valgrind
Summary: ldexpf() does not set OF flag when running in valgrind
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (other bugs)
Version First Reported In: 3.23.0
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-20 13:54 UTC by OlofZ
Modified: 2024-08-22 06:12 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description OlofZ 2024-08-20 13:54:43 UTC
SUMMARY
ldexpf() does not set OF flag when running in valgrind

STEPS TO REPRODUCE
1. Create fenv.c containing:
#include <stdio.h>
#include <fenv.h>
#include <math.h> // ldexpf()
int main() {
  float inf = ldexpf(0x4000, 0x78); // Overflow
  printf("fetestexcept(FE_OVERFLOW) = 0x%x\n", fetestexcept(FE_OVERFLOW));
}

2.  Build with:
Build with: gcc -g -lm fenv.c -o fenv

3. 

OBSERVED RESULT
$ ./fenv 
fetestexcept(0x8) = 0x8
$ valgrind ./fenv
==1226387== Memcheck, a memory error detector
==1226387== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.
==1226387== Using Valgrind-3.23.0 and LibVEX; rerun with -h for copyright info
==1226387== Command: ./fenv
==1226387== 
fetestexcept(FE_OVERFLOW) = 0x0
==1226387== 
==1226387== HEAP SUMMARY:
==1226387==     in use at exit: 0 bytes in 0 blocks
==1226387==   total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated
==1226387== 
==1226387== All heap blocks were freed -- no leaks are possible
==1226387== 
==1226387== For lists of detected and suppressed errors, rerun with: -s
==1226387== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

EXPECTED RESULT
$ valgrind ./fenv
...
fetestexcept(0x8) = 0x8
...

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
$ cat /etc/redhat-release
Red Hat Enterprise Linux release 8.7 (Ootpa)
$ uname -a
Linux seroiuts02226 4.18.0-425.19.2.el8_7.x86_64 #1 SMP Fri Mar 17 01:52:38 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux
Comment 1 Paul Floyd 2024-08-22 06:12:06 UTC
Valgrind does not support floating point exceptions, which includes the floating point status register. This might be a duplicate - I'll check in a bit.