int main(){
using T = int[2];
T arr = T{1,2};
}
Clang and GCC both rejected the example. However, according to
dcl.dcl#dcl.init.general-15.9
Otherwise, the initial value of the object being initialized is the (possibly converted) value of the initializer expression. A standard conversion sequence ([conv]) will be used, if necessary, to convert the initializer expression to the cv-unqualified version of the destination type; no user-defined conversions are considered. If the conversion cannot be done, the initialization is ill-formed. When initializing a bit-field with a value that it cannot represent, the resulting value of the bit-field is implementation-defined.
A prvalue is an expression whose evaluation initializes an object or computes the value of an operand of an operator, as specified by the context in which it appears, or an expression that has type cv void.
There's no restriction in the standard that forbids the example.The result object arr
should be initialized by the prvalue. Why do all compilers reject this example?
It is a bit different with Assignment to array in C++17, here is talking about initialization