GCC throws init-list-lifetime warning on potentially valid code?
问题 I'm running on Debian unstable with GCC 9.3.0. There was a recent change on a project I work on that introduced code similar to what's below. #include <initializer_list> #include <map> #include <vector> std::map<int, std::vector<int>> ex = []{ /* for reused lists */ std::initializer_list<int> module_options; return (decltype(ex)) { {1, module_options = { 1, 2, 3 }}, {2, module_options}, }; }(); The idea is that identical subsections of the initializer lists are first declared at the top,