I have this C++ code:
#include <iostream>
#include <vector>
class Obj {
public:
  Obj() {
    std::cout << "build" << std::endl;
  }
  ~Obj() {
    std::cout << "destroy" << std::endl;
  }
};
static std::vector<Obj> s = { Obj() };
int main() {
  return 0;
}
And the output is
build
destroy
destroy
So why does the object get destroyed twice? Shouldn't it only get destroyed once?
 
    