[UBsan] Fixed signed integer overflow
[libcds.git] / test / include / cds_test / fc_hevy_value.h
index 96db4440b70567dd3011fb979b50b3f399464b4a..4159bd7f45bcb8dd980adfc61fda21548b59df53 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SOURCE_DIRECTORY__TEST_INCLUDE_CDS_TEST_FC_HEAVY_VALUE_H_
 #define SOURCE_DIRECTORY__TEST_INCLUDE_CDS_TEST_FC_HEAVY_VALUE_H_
 
-#include <math.h>
+#include <cmath>
 #include <vector>
 
 namespace fc_test {
@@ -53,8 +53,9 @@ namespace fc_test {
             , nNo(other.nNo)
             , nWriterNo(other.nWriterNo)
         {
+            // This is an imitation of heavy copy ctor
             for(size_t i = 0; i < buffer_size; ++i)
-                pop_buff[i] =  static_cast<int>(std::sqrt(other.pop_buff[i]*rand()));
+                pop_buff[i] = static_cast<int>( std::sqrt( std::abs( static_cast<double>( pop_buff[i] ) * rand())));
         }
 
         void set_array(size_t new_size)