Skip to content

Remove -Werror=missing-braces #49133

@fwyzard

Description

@fwyzard

-Werror=missing-braces prevents CTAD:

template <std::integral... Args>
void test(Args... args) {
    auto x = std::array{static_cast<int>(args)...};
}

int main() {
    test(0, 1, 2u, 3u);
}

Once the second level of { ... } is added, it is necessary to specify the full array type:

template <std::integral... Args>
void test(Args... args) {
    auto x = std::array<int, sizeof...(Args)>{{static_cast<int>(args)...}};
}

int main() {
    test(0, 1, 2u, 3u);
}

Since c++20 seems to support this, I would argue to remove the -Werror flag.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions