https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78830
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> --- Finally, with -Waggressive-loop-optimizations -Wsystem-headers -O1 it does terminate translation: /usr/include/c++/8/bits/stl_iterator_base_funcs.h: In function ‘int main()’: /usr/include/c++/8/bits/stl_iterator_base_funcs.h:152:7: error: iteration 9223372036854775807 invokes undefined behavior [-Werror=aggressive-loop-optimizations] while (__n--) ^~~~~ /usr/include/c++/8/bits/stl_iterator_base_funcs.h:152:7: note: within this loop It's not currently possible to make this work automatically, without -Wsystem-headers.