Can't disable a clang-tidy warning
Answered
I have this, which causes no warnings, either in the IDE or when compiled:
string rtext;
int out_len1 = 1;
int out_len2 = 1;
int out_len = out_len1 + out_len2;
rtext.resize(static_cast<unsigned long>(out_len));
But when I remove the intermediate variable:
rtext.resize(static_cast<unsigned long>(out_len1 + out_len2));
... the IDE pops up a Clang-tidy warning "Clang-Tidy: Either cast from 'int' to 'unsigned long' is ineffective, or there is loss of precision before the conversion".
So no problem, I follow the suggestion light bulb and suppress the warning:
rtext.resize(static_cast<unsigned long>(out_len1 + out_len2)); // NOLINT(bugprone-misplaced-widening-cast)
This stops the IDE warning, but when I commit the code with Git, with "Perform code analysis" enabled, I still get (the same) warning.
Is there some Clang-tidy option I missed here, or is this a bug?
Thanks.
-Guy
Please sign in to leave a comment.
Hi Guy! Thanks for pointing this problem. I've created new ticket in our tracker. Please follow to get updates.