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

            Bug ID: 99081
           Summary: Misleading -Wmissing-field-initializers warning on
                    out-of-order designated initializers
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

struct A {
    int a; int b;
};

A a { .b = 1, .a = 2};

with g++ -std=c++2a -O3 -Wall -Wextra produces

<source>:5:21: warning: missing initializer for member 'A::a'
[-Wmissing-field-initializers]
    5 | A a { .b = 1, .a = 2};
      |                     ^
<source>:5:21: error: designator order for field 'A::a' does not match
declaration order in 'A'

The real problem is the error, of course, but the warning is just noise and
also incorrect - there is an initializer for a in the code, after all.

Reply via email to