https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86177
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- Lots of functions have such requirements and make it the caller's responsibility to meet those requirements. GCC is not a static analyser, you can't expect warnings about every possible bug in your code.