[Bug libstdc++/80172] Segfault when using a constructed intializer list of tuple(int, variant) created through template pack expansion

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 24 15:35:00 GMT 2017


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.


More information about the Gcc-bugs mailing list