This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/78830] New: std::prev accepts ForwardIterator-s
- From: "akrzemi1 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 16 Dec 2016 08:03:32 +0000
- Subject: [Bug libstdc++/78830] New: std::prev accepts ForwardIterator-s
- Auto-submitted: auto-generated
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.