template<int N> uint64_t shift(uint64_t b) { if (N > 0) return b << N; else return b >> -N; }
int main() { int a = shift<-5>(0x100); int b = shift<5>(0x100); return a+b; } --- I am using this function template in a header, and other warnings and even errors tend to get cluttered by the output of bogus "shift count is negative" warnings. I understand that dead code elimination happens only in the optimizer and probably to late to see that the negative shift count branch is never executed, and I could live with that if the warning was controlable with some "-W" option. Alas, it seems, it is not. The only way to supress this warning is using "-w", which also inhibits other, potential useful warnings, so using "-w" everywhere is not really an option. -- Summary: non controlable bogus warning: right/left shift count is negative Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gpiez at web dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44811