A Bug which is not a std::vector bug

来源:互联网 发布:网页小游戏源码下载 编辑:程序博客网 时间:2024/06/06 11:28

The story basically  goes like this:

/* some guy's code */struct Foo{    std::vector<int> ints;};Foo Fooes[7];.../* another guy's code */Fooes[7].ints.push_pack(5); // Bad things happened silently...Fooes[7].ints.push_pack(3); // CRASH !!!

Crash inside the std::vector code, but std::vector is totally innocent.


Then I got std::array<Foo, 7> Fooes; because it has bounds checking.


1 0