[libc-commits] [libc] [libc] Fix incorrectly enabled GPU math functions (PR #83594)

via libc-commits libc-commits at lists.llvm.org
Fri Mar 1 10:00:10 PST 2024


================
@@ -12,7 +12,7 @@
 namespace LIBC_NAMESPACE {
 
 LLVM_LIBC_FUNCTION(long long, llround, (double x)) {
-  return __builtin_llround(x);
+  return static_cast<long long>(__builtin_round(x));
----------------
lntue wrote:

Technically this is not correct, because `__builtin_round(x)` might overflow `long long` range, then you hit undefined behavior, while the behavior of `llround` with overflow values is specified.

https://github.com/llvm/llvm-project/pull/83594


More information about the libc-commits mailing list