Should I worry about Wmissing-field initializers and aggregate initialization in C ++ 17?

I compiled code with GCC with -Walland included -Wextra. This code issues a warning:

struct A { A(int) {} };
struct B {};

struct C : A, B {};

int main() {
    (void) C{1};
}
main.cpp: In function 'int main()':
main.cpp:11:15: warning: missing initializer for member 'C::<anonymous>' [-Wmissing-field-initializers]
     (void) C{1};
               ^

Should I worry about this? Is there a bug in GCC to display this warning? It seems I do not have a field for initialization and missing parameters.

+6
source share
1 answer

++ 17 . ( ). , , C "": C::A C::B.

.

, , B . -Wall :

struct C
{
  A a;
  B b;
};

(void) C{1};

. , B: (void)C{1, {}};.

, . B . .

+7

All Articles