Consider this code: auto foo(long); int i = 0; foo(i + 1); ^ warning: either cast from 'int' to 'long' is ineffective, or there is loss of precision before the conversion [misc-misplaced-widening-cast] The warning suggest that I should cast i to long, then doing the arithmetic, and then passing it to foo, _OR_ that I should remove the cast from i to long by changing the function signature. > If there is no loss of precision then the cast can be removed But this is false at least for all the functions outside your control (e.g. functions declared in external or system headers). You cannot change those, hence, you cannot remove the cast. I don't know what should be done here, but a first step could be to offer more fine tuned control about which kind of implicit cases can be disabled. I would like to disable the case in which the implicit conversion happens when calling a function (but maybe others want to keep it).
I've noticed the same issue when trying the check on our code. Assigning to the author of the check.
I did not intend to show any warnings for implicit casts. I see no reason at all to warn here in this case. Nor other similar cases. Gabor added checking for implicit casts here: http://reviews.llvm.org/D17987 And since april that checking is off by default: https://reviews.llvm.org/D32164 Because "Users reported some false positives using this check". I cant reproduce with latest revision unless I manually enable the CheckImplicitCasts option: clang-tidy -checks=* -config="{CheckOptions: [{key: misc-misplaced-widening-cast.CheckImplicitCasts, value: 1}]}" 32246.c -- I close this as worksforme. Feel free to reopen if you still see problems.