[Bug c++/49122] [C++0x] initializer_list is broken
paolo.carlini at oracle dot com
gcc-bugzilla@gcc.gnu.org
Mon May 23 14:52:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49122
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-23 14:19:40 UTC ---
If we *really* have to use the word broken here, it much better applies to your
snippet, not the implementation of std::initializer_list: an initializer_list
is essentially just a pointer (+ a length) into something else (open the header
and you will see it): thus, f is returning a pointer to the {a, b} which by
itself goes away when f returns. Anything can happen. Compare:
std::initializer_list<int> f(int a, int b)
{
static auto range = {a, b};
return range;
}
...
More information about the Gcc-bugs
mailing list