STL on user OS - std :: list works, but std :: vector does not work

I just play with the C ++ bootable boot kernel in visual studio 2010.

I got to the point that I have new and deleted records, and things like the work of dynamically distributed arrays. For example, I can use STL lists. I even sort them after I wrote the memcpy procedure. The problem is that I am using the type std :: vector. Simple vector construction sends the core to the ground.

Obviously, I miss some feature, but I looked through the STL and found it empty-handed. It does not work on push_back:

vector<int> v; v.push_back(1); 

and disappears on the air.

Any guesses on what I am missing?

Edit yes it vector of int. Sorry for the confusion. Not only this, but not the constructor with which it fails, it is a call to push_back.

+4
source share
3 answers

According to our discussion above, creating

 std::vector<mySimpleStruct> v; 

instead

 std::vector<int> v; 

seems to work correctly. This should mean that the problem is related to what is being done in specializing some functions for std :: vector in the standard template library. I assume that you are already familiar with the specialization of templates, but in case you do not:

http://www.parashift.com/c++-faq-lite/templates.html#faq-35.7

Also, once you figure out where the real problem is, could you come back and post the answer here? I wonder where the real problem is, plus the answer may be useful for others trying to build their own OS kernels.

+5
source

Blow in the dark: do you have new[] and delete[] ? The list will create one item at a time with new , while the vector will most likely allocate larger blocks of memory with new[] .

+6
source

Are you using a custom dispenser or default?

You can try using a custom option to see which allocations of vector signals can lead to the destruction of your memory manager implementation (this is probably what actually fails).

And yes, please send a message after you solve it - it helps all the other OSdevers there.

+1
source

All Articles