[llvm-bugs] [Bug 49326] New: <math.h> wrapper functions break <fenv.h> functionality
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Feb 22 20:35:43 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49326
Bug ID: 49326
Summary: <math.h> wrapper functions break <fenv.h>
functionality
Product: libc++
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: richard-llvm at metafoo.co.uk
CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
Depends on: 49325
libc++'s <math.h> wrapper functions are built in FENV_ACCESS OFF mode. This
means that LLVM will generate code for them assuming that they can only be
called in the default rounding mode. This causes calls to them in non-default
rounding modes to not work:
https://godbolt.org/z/zr4bdY
#include <cfenv>
#include <cmath>
#include <cstdio>
#pragma STDC FENV_ACCESS ON
int main(void) {
auto default_rounding = std::fegetround();
std::fesetround(FE_UPWARD);
std::printf("%+4.1f", std::rint(10.5f));
std::fesetround(default_rounding);
}
... incorrectly prints '+10.0' when compiled with '-O2 -stdlib=libc++'.
Presumably we should define the wrapper functions in an FENV_ACCESS ON region.
In order for this to not introduce a performance regression, we'll presumably
need part (3) of #49325 fixed first.
Referenced Bugs:
https://bugs.llvm.org/show_bug.cgi?id=49325
[Bug 49325] changing the floating point environment interacts badly with
interprocedural optimizations
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210223/1629802b/attachment.html>
More information about the llvm-bugs
mailing list