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

            Bug ID: 107434
           Summary: Wrong -Wmissing-field-initializers for C++ designated
                    initializers
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chfast at gmail dot com
  Target Milestone: ---

If a struct S has a field c of type C having user constructor the
"missing-field-initializers" is reported for this field even though designated
initializers are used.

struct C
{
    int x = 0;
};

struct S
{
    C c;
    bool flag = false;

};

S test()
{
    return {.flag = true};
}

<source>: In function 'S test()':
<source>:15:25: warning: missing initializer for member 'S::c'
[-Wmissing-field-initializers]
   15 |     return {.flag = true};
      |                         ^

https://godbolt.org/z/sxc8PP7Pq

Reply via email to