cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

fix #10305 & #10699: FP unusedStructMember with aggregate initialization

Open ludviggunne opened this issue 1 year ago • 3 comments

Compares number of non-static members with number of entries in braced initializer.

ludviggunne avatar Sep 12 '24 13:09 ludviggunne

10699 Can be added to title as it's pretty much the same.

olabetskyi avatar Sep 12 '24 14:09 olabetskyi

In my humble opinion here is a better test case. There should be no "unusedStructMember" warning here:

struct S {
    int a;
};

S foo() {
    return S{0};
}

danmar avatar Sep 28 '24 10:09 danmar

I realize know that this doesn't actually solve the main in example in #10305 (only the simpler one in the comments), since it relies on the name of the struct appearing before the braced initalizer. So this will require some more work.

ludviggunne avatar Sep 28 '24 11:09 ludviggunne