Skip to content

Comments

Fix truncation of value warning#2894

Merged
ronghanghu merged 1 commit intoBVLC:masterfrom
mfigurnov:fix-truncation-warning
Aug 30, 2015
Merged

Fix truncation of value warning#2894
ronghanghu merged 1 commit intoBVLC:masterfrom
mfigurnov:fix-truncation-warning

Conversation

@mfigurnov
Copy link
Contributor

Compilation of Caffe on Yosemite with Clang raises the following warning:

CXX src/caffe/common.cpp
src/caffe/common.cpp:28:10: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
  seed = abs(((s * 181) * ((pid - 83) * 359)) % 104729);
         ^
src/caffe/common.cpp:28:10: note: use function 'std::abs' instead
  seed = abs(((s * 181) * ((pid - 83) * 359)) % 104729);
         ^~~
         std::abs
1 warning generated.

This warning is obviously a false positive, since the argument is within the range of int due to the modulo operation. However, for peace of mind, I fixed the warning by replacing abs with std::abs.

ronghanghu added a commit that referenced this pull request Aug 30, 2015
@ronghanghu ronghanghu merged commit d3dc7b4 into BVLC:master Aug 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants