Is the comma (,
) a sequence point in std::initializer_list
?
example: is this UB or not:
#include <vector>
int main()
{
auto nums = []
{
static unsigned x = 2;
return ( x++ % 2 ) + 1;
};
std::vector< int > v{ nums(), nums(), nums(), nums(), nums() };
// not sure if this is different: (note the additional brackets)
// std::vector< int > v({ nums(), nums(), nums(), nums(), nums() });
for( auto i : v )
{
std::cout << i;
}
return 0;
}
According to C++11 ยง 8.5.4 [dcl.init.list] paragraph 4:
As far as I know GCC 4.8.1 has a bug relative to evaluation of initializers. I described it here
http://cpp.forum24.ru/?1-3-0-00000063-000-0-0-1378892425
Though the text is written in Russion but it can be simply translated in English by using for example google translate.