-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Closed
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
PR #126846 started diagnosing unary negations. IMO that makes sense as in the following example it's going to narrow immediately, so the warning seems justified.
However, should we also warn for practically any other unary and binary operators that apply the standard integer promotion to int (if it was shorter than an int before)?
Like in i = i | 1;?
https://godbolt.org/z/3sEEWj8b7
unsigned short unary_negate(unsigned short i) {
i = ~I; // we get the warning here
return i;
}
unsigned short binary_or(unsigned short i) {
i = i | 1; // why not also warn here?
return i;
}Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!