public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/102301] New: make_from_tuple can not work with subrange
@ 2021-09-13  3:54 hewillk at gmail dot com
  2021-09-13  4:04 ` [Bug libstdc++/102301] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: hewillk at gmail dot com @ 2021-09-13  3:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102301
           Summary: make_from_tuple can not work with subrange
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

I don't know if it is a bug, because the standard does not specify whether
make_from_tuple can be applied to subrange even if it looks well-formed, so
this may only be regarded as a feature request. 

Given that MSVC-STL already supports it, I think it should have some value.

#include <ranges>
#include <vector>

int main() {
  auto v =
std::make_from_tuple<std::vector<int>>(std::ranges::subrange(std::views::iota(0,
5)));
}

https://godbolt.org/z/Ebx83z4s1

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
@ 2021-09-13  4:04 ` pinskia at gcc dot gnu.org
  2021-09-13  4:22 ` hewillk at gmail dot com
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-13  4:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Even LLVM's libc++ does not support this ...

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
  2021-09-13  4:04 ` [Bug libstdc++/102301] " pinskia at gcc dot gnu.org
@ 2021-09-13  4:22 ` hewillk at gmail dot com
  2021-09-13  9:24 ` redi at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hewillk at gmail dot com @ 2021-09-13  4:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Even LLVM's libc++ does not support this ...

I think you are right, but I want to know what libstdc++ thinks about this
issue.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
  2021-09-13  4:04 ` [Bug libstdc++/102301] " pinskia at gcc dot gnu.org
  2021-09-13  4:22 ` hewillk at gmail dot com
@ 2021-09-13  9:24 ` redi at gcc dot gnu.org
  2021-09-13  9:28 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-13  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-09-13
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
   Target Milestone|---                         |10.4

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> Even LLVM's libc++ does not support this ...

Does libc++ even define subrange yet?

It looks like we don't define the tuple_size and tuple_element specializations
for subrange, probably because I didn't realise they were needed.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-13  9:24 ` redi at gcc dot gnu.org
@ 2021-09-13  9:28 ` redi at gcc dot gnu.org
  2021-09-13 10:16 ` hewillk at gmail dot com
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-13  9:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oh no, Patrick added them in r10-6508, and after PR 97512 it should work. Hmm.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (3 preceding siblings ...)
  2021-09-13  9:28 ` redi at gcc dot gnu.org
@ 2021-09-13 10:16 ` hewillk at gmail dot com
  2021-09-13 10:18 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hewillk at gmail dot com @ 2021-09-13 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> Oh no, Patrick added them in r10-6508, and after PR 97512 it should work.
> Hmm.

I think it should not work because make_from_tuple uses std::get inside and is
defined before using ranges::get, this will cause some namespace and ADL
mechanisms to prevent it from being selected.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (4 preceding siblings ...)
  2021-09-13 10:16 ` hewillk at gmail dot com
@ 2021-09-13 10:18 ` redi at gcc dot gnu.org
  2021-09-13 10:29 ` hewillk at gmail dot com
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-13 10:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Ugh, std::get is such a fragile and horrible API.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (5 preceding siblings ...)
  2021-09-13 10:18 ` redi at gcc dot gnu.org
@ 2021-09-13 10:29 ` hewillk at gmail dot com
  2022-04-06  3:07 ` de34 at live dot cn
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: hewillk at gmail dot com @ 2021-09-13 10:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Jonathan Wakely from comment #6)
> Ugh, std::get is such a fragile and horrible API.

Agreed, BTW PR 97512 was the first libstdc++ bug I reported, thank you for
letting me back to the old days.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (6 preceding siblings ...)
  2021-09-13 10:29 ` hewillk at gmail dot com
@ 2022-04-06  3:07 ` de34 at live dot cn
  2022-04-13  7:20 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: de34 at live dot cn @ 2022-04-06  3:07 UTC (permalink / raw)
  To: gcc-bugs

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

Jiang An <de34 at live dot cn> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |de34 at live dot cn

--- Comment #8 from Jiang An <de34 at live dot cn> ---
I've submitted an LWG issue for this.

BTW, it's unfortunate that the standard library has both tuple-like and
variant-like std::get overloads, and they are not clearly distinguished in the
specification...

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (7 preceding siblings ...)
  2022-04-06  3:07 ` de34 at live dot cn
@ 2022-04-13  7:20 ` redi at gcc dot gnu.org
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-13  7:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
https://cplusplus.github.io/LWG/issue3690

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (8 preceding siblings ...)
  2022-04-13  7:20 ` redi at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
  2022-07-28  7:34 ` de34 at live dot cn
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (9 preceding siblings ...)
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
@ 2022-07-28  7:34 ` de34 at live dot cn
  2023-01-24 23:51 ` cvs-commit at gcc dot gnu.org
  2023-07-07  9:46 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: de34 at live dot cn @ 2022-07-28  7:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Jiang An <de34 at live dot cn> ---
I think the P2165R4 has clarifed that std::make_from_tuple etc. need to be
applicable to std::ranges::subrange. And a large part of LWG3690 becomes NAD in
C++23 - tuple-like utilities no longer touch std::variant or classes derived
from tuple-like types.

But the standard wording does not yet guarantee that std::get overloads must be
found.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (10 preceding siblings ...)
  2022-07-28  7:34 ` de34 at live dot cn
@ 2023-01-24 23:51 ` cvs-commit at gcc dot gnu.org
  2023-07-07  9:46 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-24 23:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:33ed11085837e9492c6ed512931f5b6375c68ee7

commit r13-5338-g33ed11085837e9492c6ed512931f5b6375c68ee7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jan 23 12:25:36 2023 +0000

    libstdc++: Include std::ranges::subrange definition in <tuple> [PR102301]

    In order for std::make_from_tuple to work with tuple-like types, the
    overloads of std::get for those types must have been declared before the
    definition of std::make_from_tuple. That means we need to include the
    definition of std::ranges::subrange in <tuple>.

    The definitions of std::pair and its overloads of std::get are already
    included in <tuple>. We provide forward declarations of std::array and
    its std::get overloads in <tuple>. We could just declare subrange
    without defining it, and give ranges::get a non-deduced return type,
    like so:

      namespace ranges
      {
        enum class subrange_kind : bool { unsized, sized};

        template<input_or_output_iterator I, sentinel_for<I> S,
                 subrange_kind K>
          requires (K == subrange_kind::sized || !sized_sentinel_for<S, I>)
          class subrange;

        template<size_t _Num, class _It, class _Sent, subrange_kind _Kind>
          requires (_Num < 2)
          constexpr __conditional_t<_Num == 0, _It, _Sent>
          get(const subrange<_It, _Sent, _Kind>& __r);

        template<size_t _Num, class _It, class _Sent, subrange_kind _Kind>
          requires (_Num < 2)
          constexpr __conditional_t<_Num == 0, _It, _Sent>
          get(subrange<_It, _Sent, _Kind>&& __r)
      }
      using ranges::get;

    It is a bit late in the GCC 13 dev cycle to do this, so just include the
    right headers for now.

    Also add the dangling check to std::make_from_tuple added by P2255.

    libstdc++-v3/ChangeLog:

            PR libstdc++/102301
            * include/bits/ranges_base.h: Include <bits/stl_iterator.h> for
            std::make_reverse_iterator.
            * include/std/tuple: Include <bits/ranges_util.h> for subrange.
            (make_from_tuple): Add static assertion from P2255 to diagnose
            dangling references.
            * testsuite/20_util/tuple/make_from_tuple/dangling_ref.cc: New
test.
            * testsuite/20_util/tuple/make_from_tuple/tuple_like.cc: New test.

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

* [Bug libstdc++/102301] make_from_tuple can not work with subrange
  2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
                   ` (11 preceding siblings ...)
  2023-01-24 23:51 ` cvs-commit at gcc dot gnu.org
@ 2023-07-07  9:46 ` rguenth at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07  9:46 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |---

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

end of thread, other threads:[~2023-07-07  9:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13  3:54 [Bug libstdc++/102301] New: make_from_tuple can not work with subrange hewillk at gmail dot com
2021-09-13  4:04 ` [Bug libstdc++/102301] " pinskia at gcc dot gnu.org
2021-09-13  4:22 ` hewillk at gmail dot com
2021-09-13  9:24 ` redi at gcc dot gnu.org
2021-09-13  9:28 ` redi at gcc dot gnu.org
2021-09-13 10:16 ` hewillk at gmail dot com
2021-09-13 10:18 ` redi at gcc dot gnu.org
2021-09-13 10:29 ` hewillk at gmail dot com
2022-04-06  3:07 ` de34 at live dot cn
2022-04-13  7:20 ` redi at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2022-07-28  7:34 ` de34 at live dot cn
2023-01-24 23:51 ` cvs-commit at gcc dot gnu.org
2023-07-07  9:46 ` rguenth 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).