[PATCH] D22445: Avoid UB in maxIntN(64).

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 16 19:58:25 PDT 2016


majnemer added a subscriber: majnemer.

================
Comment at: include/llvm/Support/MathExtras.h:348
@@ -347,1 +347,3 @@
+  // uint64_t to avoid UB.
+  return static_cast<uint64_t>(INT64_C(1) << (N - 1)) - 1;
 }
----------------
I'd just rewrite it as:
  (UINT64_C(1)<<(N-1)) - 1


https://reviews.llvm.org/D22445





More information about the llvm-commits mailing list