Please consider this simplified C++14 program:
#include <vector>
#include <iostream>
int main()
{
auto l12 = {1,2};
auto copy = []( auto v ) { return v; };
std::vector<int> v{ copy( l12 ) };
std::cout << v[0] << ' ' << v[1] << '\n';
}
GCC here issues the warning:
warning: returning local 'initializer_list' variable 'v' does not extend the lifetime of the underlying array [-Winit-list-lifetime]
7 | auto copy = []( auto v ) { return v; };
while other compilers accept the program: https://gcc.godbolt.org/z/PPrsWxbfM
Could you please say whether the program is ill-formed or GCC warning is wrong?