Advertisement
PVS-StudioWarnings

PVS-Studio warning V636 for V8

Nov 27th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. unsigned total_size_;
  2. double source_size_in_kb =
  3.   static_cast<double>(source_size_) / 1024;
  4.  
  5. void HStatistics::Print() {
  6.   ....
  7.   double normalized_size_in_kb = source_size_in_kb > 0
  8.       ? total_size_ / 1024 / source_size_in_kb
  9.       : 0;
  10.   PrintF("%32s %8.3f ms           %7.3f kB allocated\n",
  11.          "Average per kB source",
  12.          normalized_time, normalized_size_in_kb);
  13. }
  14.  
  15. This suspicious code was found in V8 project by PVS-Studio static code analyzer.
  16. Warning message is:
  17. V636 The 'total_size_ / 1024' expression was implicitly casted from 'int' type to 'double' type. Consider utilizing an explicit type cast to avoid the loss of a fractional part. An example: double A = (double)(X) / Y;. hydrogen.cc 11023
  18.  
  19. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement