https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80172
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- I don't think this is valid code, that's not how std::initializer_list works. It's not a magic array that owns its contents, it's just a pointer to some external array and a length. In your functions the array is a local variable inside the function, and you return a dangling initializer_list object that refers to the local array. If you return std::array<blah, sizeof...(I)> it works fine.