public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/106803] New: views::adjacent_transform should not return views::empty<tuple<>> when N == 0
@ 2022-09-01 16:37 hewillk at gmail dot com
  2022-09-01 16:43 ` [Bug libstdc++/106803] " hewillk at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hewillk at gmail dot com @ 2022-09-01 16:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106803
           Summary: views::adjacent_transform should not return
                    views::empty<tuple<>> when N == 0
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

views::adjacent_transform seems to incorrectly copy-paste views::adjacent's
operator(), which makes it return views​::​empty<tuple<>> when N == 0, however,
according to the standard, it should return views​::​zip_transform(F) which is
views::empty<decay_t<invoke_result_t<FD&>>>.

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

* [Bug libstdc++/106803] views::adjacent_transform should not return views::empty<tuple<>> when N == 0
  2022-09-01 16:37 [Bug libstdc++/106803] New: views::adjacent_transform should not return views::empty<tuple<>> when N == 0 hewillk at gmail dot com
@ 2022-09-01 16:43 ` hewillk at gmail dot com
  2022-09-01 17:10 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: hewillk at gmail dot com @ 2022-09-01 16:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from 康桓瑋 <hewillk at gmail dot com> ---
Another issue is that views::zip_transform returns
views::empty<decay_t<invoke_result_t<_Fp>>> when N == 0, which is not strictly
true, the standard requires that the return is the result of the *lvalue* F
being invoked, that is, views::empty<decay_t<invoke_result_t<decay_t<_Fp>&>>>.

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

* [Bug libstdc++/106803] views::adjacent_transform should not return views::empty<tuple<>> when N == 0
  2022-09-01 16:37 [Bug libstdc++/106803] New: views::adjacent_transform should not return views::empty<tuple<>> when N == 0 hewillk at gmail dot com
  2022-09-01 16:43 ` [Bug libstdc++/106803] " hewillk at gmail dot com
@ 2022-09-01 17:10 ` ppalka at gcc dot gnu.org
  2022-09-09 19:05 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-09-01 17:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-09-01

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Whoops, thanks.

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

* [Bug libstdc++/106803] views::adjacent_transform should not return views::empty<tuple<>> when N == 0
  2022-09-01 16:37 [Bug libstdc++/106803] New: views::adjacent_transform should not return views::empty<tuple<>> when N == 0 hewillk at gmail dot com
  2022-09-01 16:43 ` [Bug libstdc++/106803] " hewillk at gmail dot com
  2022-09-01 17:10 ` ppalka at gcc dot gnu.org
@ 2022-09-09 19:05 ` cvs-commit at gcc dot gnu.org
  2022-09-09 19:09 ` ppalka at gcc dot gnu.org
  2022-09-10  3:39 ` hewillk at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-09 19:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:8298427f6b546cabb853edd45c009cd1967b9d38

commit r13-2569-g8298427f6b546cabb853edd45c009cd1967b9d38
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Sep 9 14:59:14 2022 -0400

    libstdc++: Fix return type of empty zip_/adjacent_transform [PR106803]

            PR libstdc++/106803

    libstdc++-v3/ChangeLog:

            * include/std/ranges (views::_ZipTransform::operator()): Correct
            return type in the empty case.
            (views::_AdjacentTransform::operator()): Likewise.

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

* [Bug libstdc++/106803] views::adjacent_transform should not return views::empty<tuple<>> when N == 0
  2022-09-01 16:37 [Bug libstdc++/106803] New: views::adjacent_transform should not return views::empty<tuple<>> when N == 0 hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2022-09-09 19:05 ` cvs-commit at gcc dot gnu.org
@ 2022-09-09 19:09 ` ppalka at gcc dot gnu.org
  2022-09-10  3:39 ` hewillk at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-09-09 19:09 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0
             Status|NEW                         |RESOLVED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed, thanks very much for the bug reports.

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

* [Bug libstdc++/106803] views::adjacent_transform should not return views::empty<tuple<>> when N == 0
  2022-09-01 16:37 [Bug libstdc++/106803] New: views::adjacent_transform should not return views::empty<tuple<>> when N == 0 hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2022-09-09 19:09 ` ppalka at gcc dot gnu.org
@ 2022-09-10  3:39 ` hewillk at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: hewillk at gmail dot com @ 2022-09-10  3:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Patrick Palka from comment #4)
> Fixed, thanks very much for the bug reports.

Hey Patrick, thanks for the prompt fix. 
However, I think there may be some issues with this fix, consider:

  struct F {
    F() = default;
    F(const F&) = delete;
    void operator()() = delete;
  };
  auto r = std::views::zip_transform(F{});

There are two problems here, the first less important one is that F is not
callable, so views::empty<...> in the function body would be a hard error; the
second one is that when empty pack, [range.zip.transform.overview] explicitly
requires that F must be copy_constructible (this should be move_constructible
because of p2494, I have submitted LWG for this), so even if F provides
operator(), we still need to reject the above.

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

end of thread, other threads:[~2022-09-10  3:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01 16:37 [Bug libstdc++/106803] New: views::adjacent_transform should not return views::empty<tuple<>> when N == 0 hewillk at gmail dot com
2022-09-01 16:43 ` [Bug libstdc++/106803] " hewillk at gmail dot com
2022-09-01 17:10 ` ppalka at gcc dot gnu.org
2022-09-09 19:05 ` cvs-commit at gcc dot gnu.org
2022-09-09 19:09 ` ppalka at gcc dot gnu.org
2022-09-10  3:39 ` hewillk at gmail dot com

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).