public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96868] New: C++20 designated initializer erroneous warnings
@ 2020-08-31 12:57 matt at godbolt dot org
  2020-09-01  1:11 ` [Bug c++/96868] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: matt at godbolt dot org @ 2020-08-31 12:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96868
           Summary: C++20 designated initializer erroneous warnings
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: matt at godbolt dot org
  Target Milestone: ---

The following code, with -Wall -Wextra, GCC 10.x or trunk, -std=c++20:

```
struct MyObj {
    MyObj();
};

struct Test {
    int a{};
    MyObj obj;
};

Test t() {
    Test t{.a = 1};

    return t;
}

```

Creates a warning:

```
<source>: In function 'Test t()':

<source>:11:18: warning: missing initializer for member 'Test::obj'
[-Wmissing-field-initializers]
   11 |     Test t{.a = 1};
      |                  ^
```

The "obj" is not missing initialization: the generated code correctly calls
MyObj::MyObj().

clang issues no diagnostic on the same code (even with -Weverything).

May be a duplicate of bug #82283 or bug #84685, but those have far more
complex-looking initialiser lists.

CE link: https://godbolt.org/z/b75P6r

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

end of thread, other threads:[~2023-08-21 17:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 12:57 [Bug c++/96868] New: C++20 designated initializer erroneous warnings matt at godbolt dot org
2020-09-01  1:11 ` [Bug c++/96868] " mpolacek at gcc dot gnu.org
2020-09-01  2:47 ` matt at godbolt dot org
2021-11-22  9:35 ` redi at gcc dot gnu.org
2022-02-10 21:15 ` dzhioev at gmail dot com
2022-10-27 14:51 ` pinskia at gcc dot gnu.org
2022-10-29 12:27 ` chfast at gmail dot com
2023-06-08 18:00 ` mpolacek at gcc dot gnu.org
2023-06-09 14:23 ` cvs-commit at gcc dot gnu.org
2023-08-21 17:44 ` roland at gnu dot 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).