public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107463] New: Better error request for invalid initializer list of aggregate
@ 2022-10-30 17:01 nightstrike at gmail dot com
  2022-10-30 18:30 ` [Bug c++/107463] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: nightstrike at gmail dot com @ 2022-10-30 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107463
           Summary: Better error request for invalid initializer list of
                    aggregate
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

struct S {
    struct Config {
        int x;
    };
    S(Config const & cfg);
};

void f() {
    S s({
        .y = "x"
    });
}

results in:

<source>: In function 'void f()':
<source>:11:6: error: no matching function for call to 'S::S(<brace-enclosed
initializer list>)'
   11 |     });
      |      ^
<source>:5:5: note: candidate: 'S::S(const Config&)'
    5 |     S(Config const & cfg);
      |     ^
<source>:5:22: note:   no known conversion for argument 1 from '<brace-enclosed
initializer list>' to 'const S::Config&'
    5 |     S(Config const & cfg);
      |       ~~~~~~~~~~~~~~~^~~
<source>:1:8: note: candidate: 'constexpr S::S(const S&)'
    1 | struct S {
      |        ^
<source>:1:8: note:   no known conversion for argument 1 from '<brace-enclosed
initializer list>' to 'const S&'
<source>:1:8: note: candidate: 'constexpr S::S(S&&)'
<source>:1:8: note:   no known conversion for argument 1 from '<brace-enclosed
initializer list>' to 'S&&'



It would be a lot more helpful if the error was something like "there's no
member named y in Config, did you mean x?"

PR71542 seems related, but different.

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

* [Bug c++/107463] Better error request for invalid initializer list of aggregate
  2022-10-30 17:01 [Bug c++/107463] New: Better error request for invalid initializer list of aggregate nightstrike at gmail dot com
@ 2022-10-30 18:30 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-30 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=90475
   Last reconfirmed|                            |2022-10-30
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, related to PR 90475.

Note clang in this case is just as bad as GCC (unlike PR 90475):
<source>:9:7: error: no matching constructor for initialization of 'S'
    S s({
      ^ ~
<source>:1:8: note: candidate constructor (the implicit copy constructor) not
viable: cannot convert initializer list argument to 'const S'
struct S {
       ^
<source>:1:8: note: candidate constructor (the implicit move constructor) not
viable: cannot convert initializer list argument to 'S'
struct S {
       ^
<source>:5:5: note: candidate constructor not viable: cannot convert
initializer list argument to 'const Config'
    S(Config const & cfg);
    ^

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

end of thread, other threads:[~2022-10-30 18:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-30 17:01 [Bug c++/107463] New: Better error request for invalid initializer list of aggregate nightstrike at gmail dot com
2022-10-30 18:30 ` [Bug c++/107463] " pinskia 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).