According to the g++ man-page and their website https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html , the following code should produce a warning when compiled with -O3 -Wstrict-overflow=5 :
#include <iostream>
#include <limits>
int
main() {
int x{std::numeric_limits<int>::max()};
if(x+1 > x) std::cout << "Hello";
}
https://godbolt.org/z/57ccc33f3
It even outputs "Hello", showing that it optimized the check(x+1 > x) away. However I get no warning. Do I misunderstand what this warning is meant to do or is this a gcc bug? I couldn't find anything in their bug database.