public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/97828] New: std::ranges::search_n does not work with counted_iterator<_List_iterator<...>>
@ 2020-11-14 15:32 ensadc at mailnesia dot com
  2020-11-16 11:24 ` [Bug libstdc++/97828] " ensadc at mailnesia dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ensadc at mailnesia dot com @ 2020-11-14 15:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97828

            Bug ID: 97828
           Summary: std::ranges::search_n does not work with
                    counted_iterator<_List_iterator<...>>
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ensadc at mailnesia dot com
  Target Milestone: ---

```
#include <ranges>
#include <algorithm>
#include <iostream>
#include <list>

int main() {
    using namespace std::ranges;
    std::list a = {0,42,42,0,42,42,42,0};
    auto b = a | views::take(5);
    auto count = 3;

    auto res = search_n(b, count, 42);

    for (int v : res) std::cout << v << ' ';
    std::cout << '\n';
}
```

This gives a rather long error message.

It appears that the `sized_sentinel_for` branch of std::ranges::search_n uses
random access iterator operations, without checking if the iterator is actually
random access.

(This branch also returns incorrect results for certain input, which can be
observed by changing `std::list` to `std::vector`.)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-11-17 16:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-14 15:32 [Bug libstdc++/97828] New: std::ranges::search_n does not work with counted_iterator<_List_iterator<...>> ensadc at mailnesia dot com
2020-11-16 11:24 ` [Bug libstdc++/97828] " ensadc at mailnesia dot com
2020-11-16 11:34 ` ensadc at mailnesia dot com
2020-11-16 16:06 ` space.mission at yandex dot ru
2020-11-16 16:33 ` redi at gcc dot gnu.org
2020-11-16 16:36 ` redi at gcc dot gnu.org
2020-11-16 17:22 ` ppalka at gcc dot gnu.org
2020-11-16 20:26 ` ppalka at gcc dot gnu.org
2020-11-17 15:29 ` cvs-commit at gcc dot gnu.org
2020-11-17 16:28 ` cvs-commit at gcc dot gnu.org
2020-11-17 16:30 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).