Clang compiler warning for IntTSC (-Wsign-compare)
Summary
Clang compiler warning for IntTSC (-Wsign-compare).
Steps to reproduce
-- The C compiler identification is Clang 9.0.1
-- The CXX compiler identification is Clang 9.0.1
-- Check for working C compiler: /opt/local/bin/mpicc-mpich-clang90
Relevant logs and/or screenshots
ippl/src/Particle/IntTSC.h:284:8: error: comparison of integers of
different signs: 'unsigned int' and 'int' [-Werror,-Wsign-compare]
if (p==-1) return .125*(1.-4.*dpos(i)+4.*dpos(i)*dpos(i));
~^ ~~
and many similar ones
Possible fixes
The warning comes from https://gitlab.psi.ch/OPAL/src/blob/master/ippl/src/Particle/IntTSC.h#L283
auto W = [dpos](unsigned p, unsigned i) {
if (p==-1) return .125*(1.-4.*dpos(i)+4.*dpos(i)*dpos(i));
else if (p==0) return .25*(3.-4.*dpos(i)*dpos(i));
else if (p==+1) return .125*(1.+4.*dpos(i)+4.*dpos(i)*dpos(i)); };
p
should be a signed integer instead of unsiged.
Edited by snuverink_j