Skip to content

clang-tidy's readability-redundant-member-init has false positives for aggregates #119094

@foonathan

Description

@foonathan

The following code generates a clang-tidy warning for readability-redundant-member-init.

struct foo {
    std::string a;
    std::string b  = {};
};

However, the initializer for b is not redundant. Consider:

void expect_foo(const foo& f);

expect_foo({"hello"});

With the initializer for b present, the code is fine. Without the initializer, the code generates a missing-field-initializer warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions