I noticed that when I initialize array like so:
std::array<int,3> myarray;
myarray[0] = 9;
myarray[1] = 8;
myarray[2] = 7;
myarray[3] = 6;
myarray[4] = 5;
I do not get an error, even though I have more array elements than was defined in <int,3>
I am on Mac with g++ and it's C++11.
So I guess my question is: why is that, that there are no errors? Is it correct behavior? Or do I expect too much form my compiler?
Also what is this method of initialization called? Someone called it "buggy construction". I think they meant it as a joke though.
P.S. I understand that this method is undesirable.
EDIT: Some folks suggested that my question is a duplicate. But according to the best answer from Vlad it does not seem to be. According to Vlad my question is about operator overloading and not C style array range. I have to trust his expertise and what he said just makes sense.