public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108744] New: error message when trying to use structured bindings in static member declaration could be cleaner
@ 2023-02-09 17:31 barry.revzin at gmail dot com
  2023-02-09 17:35 ` [Bug c++/108744] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: barry.revzin at gmail dot com @ 2023-02-09 17:31 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2023-02-09 18:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 17:31 [Bug c++/108744] New: error message when trying to use structured bindings in static member declaration could be cleaner barry.revzin at gmail dot com
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

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