Is omitting nested braces legal in initialization of `std::initializer_list` of aggregates?

Viewed 120

Consider following code:

run on gcc.godbolt.org

#include <initializer_list>

struct A
{
    int x;
};

int main()
{
    std::initializer_list<A>{100};
}

Clang accepts it. GCC and MSVC reject it, with errors like:

error: no matching function for call to 'std::initializer_list<A>::initializer_list(<brace-enclosed initializer list>)'

Which compiler is correct here?

I tried looking at [dcl.init.list]/5 and [over.match.list], but didn't find anything interesting.

0 Answers
Related