[Bug libstdc++/78830] std::prev accepts ForwardIterator-s

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 22 15:36:00 GMT 2019


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.


More information about the Gcc-bugs mailing list