[PATCH] D52137: Added warning for unary minus used with unsigned type

Joerg Sonnenberger via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 16 11:25:33 PDT 2018


joerg added a comment.

I find this warning confusing. I find a4 to be perfectly expected. IMO this warning should be applied only, if the effective value of the expression is not the same as in the modulo-n arithmetic. This means that if (-x) is explicitly or implicitly cast to a less wide unsigned type, it should not warn. It would consider a warning for the case of using (-x) if integer promotion rules makes it negative though. The question is, how to best patch around the warning though. What options does MSVC have for that? I.e. what equivalent expressions do not trigger this warning?


https://reviews.llvm.org/D52137





More information about the cfe-commits mailing list