Consider:
#include <iostream>
#include <vector>
class A
{
public:
const int& i;
};
class B
{
public:
const std::vector<int>& i;
};
int main()
{
A a = { 3 };
std::cout << a.i << std::endl;
B b = { { 1, 2 } };
std::cout << b.i[0] << " " << b.i[1] << std::endl;
}
On VS2015 update 3, this crashes in runtime on the last line because the vector b.i is empty; on gcc (4.9.2) this runs OK and shows the expected output (3 1 2). So on VS it 'works' (does what I expected) for an int, but not a vector.
Is this a VS bug or is it just an accident that it works on gcc?