PVS-StudioWarnings

PVS-Studio warning V511 for Wolf

Nov 20th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. ID_INLINE mat3_t::mat3_t( float src[ 3 ][ 3 ] ) {
  2.   memcpy( mat, src, sizeof( src ) );
  3. }
  4.  
  5. The 'src' object is simply a pointer. Value 3x3 in the square brackets indicates to the programmer that he is working with an array of 3x3 items.
  6. But it is not an array of items which is passed into the function - it is only the pointer.
  7. So, the sizeof(src) expression will return value 4 or 8 (the size of the pointer in a 32-bit/64-bit system).
  8.  
  9. This suspicious code was found in Wolf project by PVS-Studio static code analyzer.
  10. Warning message is:
  11. V511 The sizeof() operator returns size of the pointer, and not of the array, in 'sizeof (src)' expression. Splines math_matrix.h 94
  12.  
  13. 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