Silencing a specific "missing braces" clang warning
10:20 28 Apr 2026

I'm triggering this warning with this snippet:

struct A {
    int x;
    int y;
};
struct B {
    int x;
    int y;
    int z;
};

struct Flatten {
    A a;
    B b;
};

int main() {
    [[maybe_unused]] Flatten arr{1, 2, 3, 4, 5};
}

LIVE

This design comes from another question where Op wanted to design a structure to "flatten" both A and B.

The initialization of Flatten arr using single braces is, AFAIU, legal but clang seem to prefer Flatten arr{{1, 2}, {3, 4, 5}};, making explicit the subaggregates initializations.

I can't think, right now, of situation where this warning would be legitimate, except for readability. Yet I'm striving for 0 warning so is there a way to silence this warning for clang in this specific situation, without silencing it for any other potentially legit situation?

c++ compiler-warnings clang++ aggregate-initialization