https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107699
--- Comment #2 from Carlos Galvez <carlosgalvezp at gmail dot com> --- Looking deeply at the stacktrace, I see that std::sort ends up in this kind of code: if (__last - __first > int(_S_threshold)) { std::__insertion_sort(__first, __first + int(_S_threshold), __comp); Since the __last iterator cannot be known at compile time, this "if" branch must be generated by the compiler. But then std::sort has hardcoded this _S_threshold = 16, and computes a pointer __first + 16, which is known to be OOB. The question is: should the compiler *really* warn in this type of code, in -Wall, which is the bare-minimum warning level for all projects? While I can see the usefulness, the sheer amount of false positives (see meta bug-tracker) does not qualify this warning from being part of -Wall IMHO. This diagnostic fits better as "-Wmaybe-array-bounds". The worst part is that people need to disable this warning globally, therefore losing warning coverage on *true* OOB accesses happening in user code.