https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107699
--- Comment #6 from Carlos Galvez <carlosgalvezp at gmail dot com> --- A similar case in the real world would be this: NumberSmallerThan3 getCount(); std::sort(data.begin(), data.begin() + static_cast<std::size_t>(getCount())); The "NumberSmallerThan3" class holds and checks the invariant that "a number is smaller than 3". The compiler is not aware of that. Other real-world situation is Eigen-like code, where for performance reasons these checks can only be applied in debug mode, not release mode. We get warnings in release mode due to this.