public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "barry.revzin at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/108744] New: error message when trying to use structured bindings in static member declaration could be cleaner
Date: Thu, 09 Feb 2023 17:31:41 +0000	[thread overview]
Message-ID: <bug-108744-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 108744
           Summary: error message when trying to use structured bindings
                    in static member declaration could be cleaner
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Consider:

struct X {
    int i, j;
};

struct C {
    static auto [a, b] = X{1, 2};
};


This is ill-formed, but the error is currently:

<source>:6:17: error: expected unqualified-id before '[' token
    6 |     static auto [a, b] = X{1, 2};
      |                 ^

clang, in contrast, says:

<source>:6:17: error: decomposition declaration not permitted in this context
    static auto [a, b] = X{1, 2};
                ^~~~~~

Which is a lot clearer. I think ideally the error states explicitly that
structured bindings can't be used in static data member declarations.

             reply	other threads:[~2023-02-09 17:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 17:31 barry.revzin at gmail dot com [this message]
2023-02-09 17:35 ` [Bug c++/108744] " pinskia at gcc dot gnu.org
2023-02-09 17:56 ` mpolacek at gcc dot gnu.org
2023-02-09 18:28 ` barry.revzin at gmail dot com

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