[libc-commits] [libc] [llvm] [libc][math][c23] Add exp10bf16 math function (PR #193299)
via libc-commits
libc-commits at lists.llvm.org
Sun Apr 26 05:17:09 PDT 2026
================
----------------
ProfessionalMenace wrote:
Currently getting an error (pasted below) after adding the test and running it. How should I proceed?
```
[1/3] Building CXX object libc/test/shared/CMakeFiles/libc.test.shared.shared_math_constexpr_test.__unit__.__build__.dir/shared_math_constexpr_test.cpp.o
FAILED: [code=1] libc/test/shared/CMakeFiles/libc.test.shared.shared_math_constexpr_test.__unit__.__build__.dir/shared_math_constexpr_test.cpp.o
/usr/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_23_0_0_git -I/home/Menace/Projects/llvm-project/libc -I/home/Menace/Projects/llvm-project/build/libc -isystem /home/Menace/Projects/llvm-project/build/libc/include -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Xclang -fno-pch-timestamp -O3 -DNDEBUG -std=gnu++17 -mavx2 -mfma -msse4.2 -D__LIBC_MISC_MATH_BASIC_OPS_OPT -D__LIBC_USE_BUILTIN_FMAX_FMIN -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_COPT_STRING_LENGTH_IMPL=clang_vector -DLIBC_COPT_FIND_FIRST_CHARACTER_IMPL=word -DLIBC_ADD_NULL_CHECKS -DLIBC_ERRNO_MODE=LIBC_ERRNO_MODE_DEFAULT -DLIBC_THREAD_MODE=LIBC_THREAD_MODE_PLATFORM -DLIBC_COPT_TIMEOUT_ENSURE_MONOTONICITY -DLIBC_CONF_WCTYPE_MODE=LIBC_WCTYPE_MODE_ASCII -DLIBC_COPT_RAW_MUTEX_DEFAULT_SPIN_COUNT=100 -fpie -ffixed-point -Wall -Wextra -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -DLIBC_TEST=UNIT -MD -MT libc/test/shared/CMakeFiles/libc.test.shared.shared_math_constexpr_test.__unit__.__build__.dir/shared_math_constexpr_test.cpp.o -MF libc/test/shared/CMakeFiles/libc.test.shared.shared_math_constexpr_test.__unit__.__build__.dir/shared_math_constexpr_test.cpp.o.d -o libc/test/shared/CMakeFiles/libc.test.shared.shared_math_constexpr_test.__unit__.__build__.dir/shared_math_constexpr_test.cpp.o -c /home/Menace/Projects/llvm-project/libc/test/shared/shared_math_constexpr_test.cpp
/home/Menace/Projects/llvm-project/libc/test/shared/shared_math_constexpr_test.cpp:104:15: error: static assertion expression is not an integral constant expression
104 | static_assert(bfloat16(1.0) == LIBC_NAMESPACE::shared::exp10bf16(bfloat16(0.0)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/Menace/Projects/llvm-project/libc/src/__support/math/exp10bf16.h:129:19: note: non-constexpr function 'nearest_integer' cannot be used in a constant expression
129 | float intPart = fputil::nearest_integer(xscaled);
| ^
/home/Menace/Projects/llvm-project/libc/test/shared/shared_math_constexpr_test.cpp:104:32: note: in call to 'exp10bf16({0})'
104 | static_assert(bfloat16(1.0) == LIBC_NAMESPACE::shared::exp10bf16(bfloat16(0.0)));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<command line>:1:24: note: expanded from macro 'LIBC_NAMESPACE'
1 | #define LIBC_NAMESPACE __llvm_libc_23_0_0_git
| ^
/home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/x86_64/nearest_integer.h:29:19: note: declared here
29 | LIBC_INLINE float nearest_integer(float x) {
| ^
In file included from /home/Menace/Projects/llvm-project/libc/test/shared/shared_math_constexpr_test.cpp:11:
In file included from /home/Menace/Projects/llvm-project/libc/shared/math.h:14:
In file included from /home/Menace/Projects/llvm-project/libc/shared/math/acos.h:13:
In file included from /home/Menace/Projects/llvm-project/libc/src/__support/math/acos.h:18:
In file included from /home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/sqrt.h:15:
In file included from /home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/generic/sqrt.h:16:
/home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/cast.h:55:18: warning: shift count is negative [-Wshift-count-negative]
55 | x_mant >>= InFPBits::FRACTION_LEN - OutFPBits::FRACTION_LEN;
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/ManipulationFunctions.h:225:7: note: in instantiation of function template specialization '__llvm_libc_23_0_0_git::fputil::cast<long double, __llvm_libc_23_0_0_git::fputil::BFloat16>' requested here
225 | if (cast<U>(from) == to)
| ^
/home/Menace/Projects/llvm-project/libc/src/__support/math/nexttowardbf16.h:22:18: note: in instantiation of function template specialization '__llvm_libc_23_0_0_git::fputil::nextafter<__llvm_libc_23_0_0_git::fputil::BFloat16, long double, 0>' requested here
22 | return fputil::nextafter(x, y);
| ^
In file included from /home/Menace/Projects/llvm-project/libc/test/shared/shared_math_constexpr_test.cpp:11:
In file included from /home/Menace/Projects/llvm-project/libc/shared/math.h:14:
In file included from /home/Menace/Projects/llvm-project/libc/shared/math/acos.h:13:
In file included from /home/Menace/Projects/llvm-project/libc/src/__support/math/acos.h:18:
In file included from /home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/sqrt.h:15:
In file included from /home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/generic/sqrt.h:16:
/home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/cast.h:55:18: warning: shift count is negative [-Wshift-count-negative]
55 | x_mant >>= InFPBits::FRACTION_LEN - OutFPBits::FRACTION_LEN;
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/Menace/Projects/llvm-project/libc/src/__support/FPUtil/ManipulationFunctions.h:225:7: note: in instantiation of function template specialization '__llvm_libc_23_0_0_git::fputil::cast<long double, _Float16>' requested here
225 | if (cast<U>(from) == to)
| ^
/home/Menace/Projects/llvm-project/libc/src/__support/math/nexttowardf16.h:26:18: note: in instantiation of function template specialization '__llvm_libc_23_0_0_git::fputil::nextafter<_Float16, long double, 0>' requested here
26 | return fputil::nextafter(x, y);
| ^
2 warnings and 1 error generated.
ninja: build stopped: subcommand failed.
```
https://github.com/llvm/llvm-project/pull/193299
More information about the libc-commits
mailing list