0

I know that a push_back can change the memory location of a std::vector when its capacity is exceeded. But can other operations do that?

In particular, is it possible that the manipulation of other vectors impact the location of the first one?

I think I observed this behaviour. Using a pointer to an element of the vector eventually makes a segfault while I don't modify the vector at all. I am unable to make a minimal example because it seems to be closely related to the rest of the memory management of my code.

fffred
  • 596
  • 4
  • 19
  • "Using a pointer to an element of the vector eventually makes a segfault while I don't modify the vector at all." - sounds surprising to me. what compiler? – asu Nov 04 '16 at 16:47
  • `std::vector` would normally manage its memory. What sort of memory management do you have in the rest of your code? – wally Nov 04 '16 at 16:49
  • @Asu i use gcc48. – fffred Nov 05 '16 at 09:10
  • @flatmouse I'm not sure what you mean by memory management. I mostly use vector, and very light use of mallocs. – fffred Nov 05 '16 at 09:10

0 Answers0