This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49122] [C++0x] initializer_list is broken
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 08 Jan 2013 12:39:26 +0000
- Subject: [Bug c++/49122] [C++0x] initializer_list is broken
- Auto-submitted: auto-generated
- References: <bug-49122-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49122
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-01-08 12:39:26 UTC ---
(In reply to comment #5)
> Hi Jonathan Wakely,
>
> Just wanted to confirm the doubt:
That's not a "doubt" it's a question.
> Do you wanted to mean that, the initializer_list<T> behaviour is exactly like
> this(work for local stack members) and there nothing work around possible to
> avoid this observation ?
Yes. If you want to pass data out of a function use a container or a tuple or
something that *copies* the data. An std::initializer_list is not a container,
it does not own or copy its elements.
The workaround is don't misuse initializer_list for something it isn't designed
to do.