public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gnaggnoyil at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/110216] New: Outdated implementation of tuple_size requirements for structured binding
Date: Mon, 12 Jun 2023 09:09:35 +0000	[thread overview]
Message-ID: <bug-110216-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2023-06-12  9:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12  9:09 gnaggnoyil at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-110216-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).