[clang++] do not emit missing braces warning if all initializers are missing the same number of braces #111542
Labels
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Currently
-Wmissing-braces
is disabled in some useful cases (see here).However the current rules still emit a warning in cases such as
This pattern is used to implement an aggregate tuple template (templating has been omitted from this example for the sake of simplicity) which is useful in cases where tuples must be able to contain immovable types such as in senders & receivers based execution libraries.
I would like to suggest a generalization of the current rules that would avoid the warning in the example above: if all initializers provided are missing the same number of enclosing pairs of braces, then don't emit the warning. So in the
std::array
case there would be no warning because an outer pair of braces is missing, while in the above tuple case there would also be no warning because each initializer would be missing an inner pair of braces. Note that under this rule there would no longer be a warning for theAggregateAndEmpty
case inaggregate-initialization.cpp
but maybe there is a refinement of the rule that would preserve the warning in that case.Currently, there is no way for library code to suppress the warning assuming that the user has turned on
-Wmissing-braces
. The warning suppression using#pragma
must be done at the site of the aggregate initialization, not the class definition.The text was updated successfully, but these errors were encountered: