vendredi 31 août 2018

destructor is called twice for std::vector with optimization level 0

I am trying to understand the assembly code generated for the std::vector and its emplace_back (or) push_back function using compiler explorer.

using emplace_back

Note: Optimization level is 0 i.e., -O0 is used

One thing that I couldn't understand is that why are there two destructors being called instead of one (As you can see only one vector is being created. If I assume that a temporary object is being created internally, then atlease I have to see a call to std::vector constructor.

This is same with clang compiler as well.

Can someone please explain what is happening here?

Aucun commentaire:

Enregistrer un commentaire