[libc++] long double
function call relies on double
function
#62282
Labels
long double
function call relies on double
function
#62282
In line 745 of file libcxx/include/cmath the following function template is defined:
This function can be called with a value of type
long double
as the first argument (e.g., line 710 of file libcxx/include/complex). However, its return statement is:return __builtin_scalbn(__x, __exp);
This other built-in function takes a
double
as the first argument (instead of along double
) and also returns adouble
(instead of along double
). This accuracy loss yields undesired results, as it can be seen in the following example (Compiler Explorer):This bug was found in
clang 16.0.0
using the SuperTest suite,clang 15.0.0
still works fine.Compilation flags:
-m64 -std=c++20 -stdlib=libc++ -O0 -funsigned-char
Replacing the call to
__builtin_scalbn()
with a call to__builtin_scalbnl()
for this case should fix it (or creating a specialization).The text was updated successfully, but these errors were encountered: