public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110216] New: Outdated implementation of tuple_size requirements for structured binding
@ 2023-06-12  9:09 gnaggnoyil at gmail dot com
  2023-06-12 19:24 ` [Bug c++/110216] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: gnaggnoyil at gmail dot com @ 2023-06-12  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110216
           Summary: Outdated implementation of tuple_size requirements for
                    structured binding
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnaggnoyil at gmail dot com
  Target Milestone: ---

The following code is rejected with `g++ -std=c++20` as of GCC 13.1:

#include <tuple>

struct A { int x; };

namespace std
{
    template<>
    struct tuple_size<::A> {};
}

auto [x] = A{};

Clang 16.0 on the other hand accepts this code with `-std=c++20` flag.

Wording of N4849 (and also the latest working draft as of today) specifies the
expected behavior in [dcl.struct.bind]#4 as follows:

    Otherwise, if the qualified-id std::tuple_size<E> names a complete class
type with a member named value, ...

Therefore, the above code shouldn't follow the requirements specified in
[dcl.struct.bind]#4 as tuple-like types. Instead, it should follow those in
[dcl.struct.bind]#5 and do the binding to data members.

This behavior change was introduced by CWG 2386 and corresponding wording
change can be found at
https://github.com/cplusplus/draft/commit/498092ced200140801180dcc9c2878a49350f946

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

end of thread, other threads:[~2024-04-11 18:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12  9:09 [Bug c++/110216] New: Outdated implementation of tuple_size requirements for structured binding gnaggnoyil at gmail dot com
2023-06-12 19:24 ` [Bug c++/110216] " pinskia at gcc dot gnu.org
2023-06-12 19:25 ` [Bug c++/110216] tuple_size requirements for structured binding has not been updated after DR 2386 pinskia at gcc dot gnu.org
2023-06-13  0:10 ` mpolacek at gcc dot gnu.org
2023-08-14 17:35 ` cvs-commit at gcc dot gnu.org
2024-04-11 18:39 ` mpolacek 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).