https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78830
Bug ID: 78830 Summary: std::prev accepts ForwardIterator-s Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: akrzemi1 at gmail dot com Target Milestone: --- The following code compiles, even though according to the C++ Standard it is ill-formed. ``` #include <forward_list> #include <algorithm> int main() { std::forward_list<int> il = {1, 2, 3, 4, 5, 6, 7}; auto iter = std::prev(il.end()); } ``` While the fix for 62039 mitigates the problem, according to the Standard this code should be rejected unconditionally. Clang does this by using enable_if trick. A static_assert would also work.