I don't understand why this doesn't work:
auto a = (int[]){1, 2, 3, 4, 5};
> error: taking address of temporary array
I understand that array lvalues decay to pointers when converted to rvalues but here the array is already an rvalue (actually a prvalue) so no decay should be needed. I would have expected a
to be deduced and initialized to int[5]
. Why is it trying to take the address of a temporary?