[PATCH] D46295: [ubsan] Make the C++ code here not cast floating point values outside the range of an integer type to that integer type.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 30 18:15:56 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL331240: [ubsan] Make the C++ code here not cast floating point values outside (authored by chandlerc, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D46295

Files:
  test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp
  test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp


Index: test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp
===================================================================
--- test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp
+++ test-suite/trunk/Bitcode/simd_ops/simd_ops.cpp
@@ -24,7 +24,7 @@
 
 template<typename T>
 T rand_value() {
-    return (T)(rand() * 0.125) - 100;
+    return (T)((T)rand() / 8) - 100;
 }
 
 // Even on android, we want errors to stdout
Index: test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp
===================================================================
--- test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp
+++ test-suite/trunk/Bitcode/Regression/vector_widen/driver.cpp
@@ -2,7 +2,7 @@
 
 template<typename T>
 T rand_value() {
-    return (T)(rand() * 0.125) - 100;
+    return (T)((T)rand() / 8) - 100;
 }
 
 template<typename T>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46295.144663.patch
Type: text/x-patch
Size: 837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180501/4258b581/attachment.bin>


More information about the llvm-commits mailing list