https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68816
--- Comment #6 from David Binderman <dcb314 at hotmail dot com> --- (In reply to Martin Sebor from comment #5) > GCC warns for this case with -O2 -Wstrict-overflow=3 so I think this bug can > be closed as invalid. I tried out the flag you suggest and it generated lots of false positives. I also tried out -Wstrict-overflow. Same result, too many false positives to be useful. Thanks for all your advice. I am happy for this bug report to be closed. Interestingly, clang doesn't find this problem either.