range based forの問題かstd::initializer_listの問題かstd::stringの問題か
$ gcc --version gcc (GCC) 4.6.0 20101002 (experimental) Copyright © 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
において、以下のコードがセグフォする。
#include <string> #include <initializer_list> int main( void ) { for ( std::string str : std::initializer_list< std::string >( { { "hoge" }, { "fuga" } } ) ) {} }
std::initializer_listのスコープがいい感じにforの途中で死んでるのか、std::stringのコピコンがダメなのか、そもそもこれはill-formedなのか。FCDを通して読んでないのでなんとも言えないけど・・・
なぜか、std::initializer_listに突っ込むのを{ { "hoge" } }1つにするとセグフォは起こらない。適当に最適化がかかってるのかな。