This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115c. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-09-25
Consider:
int f(int const(&)[]) { return 1; } // #1 int f(int const(&)[2]) { return 2; } // #2 int x = f({});
Subclause 12.2.4.2.6 [over.ics.list] paragraph 6 specifies:
Otherwise, if the parameter type is “array of N X” or “array of unknown bound of X”, if there exists an implicit conversion sequence from each element of the initializer list (and from {} in the former case if N exceeds the number of elements in the initializer list) to X, the implicit conversion sequence is the worst such implicit conversion sequence.
What is the "worst [...] implicit conversion sequence" when the initializer list is empty? Should #1 even be viable for this call, given that it's not valid to initialize an int const (&)[] from {}?
There is implementation divergence: Clang and MSVC treat #1 as being non-viable; GCC calls #1 and creates a temporary of type `int[0]` (even in -pedantic-errors mode). Should the "worst conversion sequence" over an empty set be the identity conversion, selecting #1 and then failing the parameter initialization?