The latest Visual Studio 2019 compiling the following code with /Wall
command-line switch (which enables all warnings):
struct A{};
void f( const std::array<A, 2> & ) {}
int main() {
A x, y;
f( { x, y } );
}
prints the warning:
warning C5246: 'std::array<A,2>::_Elems': the initialization of a subobject should be wrapped in braces
however both GCC and Clang accepts the code with the most pedantic error checking, demo: https://gcc.godbolt.org/z/Ps6K6jK1G
Indeed, all compilers accept the call f( { { x, y } } );
Is MSVC right in suggesting it in favor of the simpler form without extra braces?