public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/96070] New: std::views::* won't work with non-legacy iterators
@ 2020-07-06  2:08 gcc-bugs at marehr dot dialup.fu-berlin.de
  2020-07-06 10:50 ` [Bug libstdc++/96070] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gcc-bugs at marehr dot dialup.fu-berlin.de @ 2020-07-06  2:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96070
           Summary: std::views::* won't work with non-legacy iterators
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc-bugs at marehr dot dialup.fu-berlin.de
  Target Milestone: ---

Hi gcc-team,

not long ago a filed a bug-report[1] that
`std::ranges::basic_istream_view::iterator` has no `std::iterator_traits`
entry. 

> Your mistake is thinking that the iterators of views are like the iterators you're used to.

It seems that not only I had that problem, because this has some interesting
consequences for the standard, for example the
`std::ranges::filter_view::iterator` is described as [2]:

> 3 iterator​::​iterator_­category is defined as follows:
> (3.1) Let C denote the type iterator_­traits<iterator_­t<V>>​::​iterator_­category.
> (3.2) If C models derived_­from<bidirectional_­iterator_­tag>, then iterator_­category denotes bidirectional_­iterator_­tag.
> (3.3) Otherwise, if C models derived_­from<forward_­iterator_­tag>, then iterator_­category denotes forward_­iterator_­tag.
> (3.4) Otherwise, iterator_­category denotes C.

This assumes that `iterator_­traits<iterator_­t<V>>​::​iterator_­category` is
defined which is not true for all iterators, like
`std::ranges::basic_istream_view::iterator`.

A quick check with the gcc stdlib implementation:

```c++
#include <iostream>
#include <ranges>
#include <vector>

int main()
{
    // using input_view_t = std::vector<int> &; // works
    using input_view_t = std::ranges::basic_istream_view<char, char,
std::char_traits<char>>; // does not work

    auto accept_all = [](auto &&){return true;};
    using filter_input_view_t = decltype(std::declval<input_view_t>() |
std::views::filter(accept_all));
    using filter_iterator_t = std::ranges::iterator_t<filter_input_view_t>;
}
```

https://godbolt.org/z/Uozktw

And yes it does not work.

Since I don't know of a generic way to conditionally include/exclude `using
iterator_category = some_tag`, I think the easiest way would to allow
`iterator_category = void`.

We would need to change the behaviour of `std::iterator_traits`. We should not
only check whether all 4 members are available, but also that
`iterator_category` is at least an input_iterator_tag or an
output_iterator_tag. Or alternatively check that `iterator_category` is
non-void.

I don't know how to create a LWG issue and if this problem was already
reported, but I hope you can create one like in my last finding [3].

If this defect was not reported yet, it would be nice to at least link back to
this issue and not just write "A user reported that this doesn't compile: ".

[1] - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94674
[2] - https://eel.is/c++draft/range.filter.iterator#3
[3] - https://cplusplus.github.io/LWG/issue3448

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

* [Bug libstdc++/96070] std::views::* won't work with non-legacy iterators
  2020-07-06  2:08 [Bug libstdc++/96070] New: std::views::* won't work with non-legacy iterators gcc-bugs at marehr dot dialup.fu-berlin.de
@ 2020-07-06 10:50 ` redi at gcc dot gnu.org
  2020-07-08 20:06 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-06 10:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to gcc-bugs from comment #0)
> I don't know how to create a LWG issue

https://cplusplus.github.io/LWG/lwg-active.html#submit_issue

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

* [Bug libstdc++/96070] std::views::* won't work with non-legacy iterators
  2020-07-06  2:08 [Bug libstdc++/96070] New: std::views::* won't work with non-legacy iterators gcc-bugs at marehr dot dialup.fu-berlin.de
  2020-07-06 10:50 ` [Bug libstdc++/96070] " redi at gcc dot gnu.org
@ 2020-07-08 20:06 ` redi at gcc dot gnu.org
  2021-04-20 15:38 ` ppalka at gcc dot gnu.org
  2021-04-20 15:39 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-08 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=95983

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to gcc-bugs from comment #0)
> Hi gcc-team,
> 
> not long ago a filed a bug-report[1] that
> `std::ranges::basic_istream_view::iterator` has no `std::iterator_traits`
> entry. 

Which is also the cause of PR 95983.

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

* [Bug libstdc++/96070] std::views::* won't work with non-legacy iterators
  2020-07-06  2:08 [Bug libstdc++/96070] New: std::views::* won't work with non-legacy iterators gcc-bugs at marehr dot dialup.fu-berlin.de
  2020-07-06 10:50 ` [Bug libstdc++/96070] " redi at gcc dot gnu.org
  2020-07-08 20:06 ` redi at gcc dot gnu.org
@ 2021-04-20 15:38 ` ppalka at gcc dot gnu.org
  2021-04-20 15:39 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-20 15:38 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
                 CC|                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
This is also fixed by P2259R1, so let's mark this PR as a dup of PR95893.

*** This bug has been marked as a duplicate of bug 95893 ***

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

* [Bug libstdc++/96070] std::views::* won't work with non-legacy iterators
  2020-07-06  2:08 [Bug libstdc++/96070] New: std::views::* won't work with non-legacy iterators gcc-bugs at marehr dot dialup.fu-berlin.de
                   ` (2 preceding siblings ...)
  2021-04-20 15:38 ` ppalka at gcc dot gnu.org
@ 2021-04-20 15:39 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-04-20 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Whoops, rather PR95983...

*** This bug has been marked as a duplicate of bug 95983 ***

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

end of thread, other threads:[~2021-04-20 15:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-06  2:08 [Bug libstdc++/96070] New: std::views::* won't work with non-legacy iterators gcc-bugs at marehr dot dialup.fu-berlin.de
2020-07-06 10:50 ` [Bug libstdc++/96070] " redi at gcc dot gnu.org
2020-07-08 20:06 ` redi at gcc dot gnu.org
2021-04-20 15:38 ` ppalka at gcc dot gnu.org
2021-04-20 15:39 ` 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).