Confused about move semantics

Started by
1 comment, last by Adam_42 11 years, 11 months ago
This function was written by a code generator:

template <typename R>
void
Receive (::cmw::ReceiveBufferTCPCompressed<R>& buf
, ::std::vector<cmw::File>& az1
)
{
uint32_t headCount[1];
buf.Give(headCount[0]);
az1.reserve(az1.size() + headCount[0]);
for (; headCount[0] > 0; --headCount[0]) {
cmw::File rep2(buf);
az1.push_back(rep2);
}
}



My question has to do with the code in the loop. File.hh is here and File.cc is here. (All of the code in question can be downloaded here.)
If I change the last line in the loop to:
az1.push_back(::std::move(rep2));

the size of the executable is reduced by 492 bytes. I thought that since File has a user defined copy constructor and destructor, the compiler wouldn't generate a move constructor for the class. I figured the compiler would ignore the std::move call and use the copy constructor and the two versions would produce the same size executables. What am I missing? Thanks.

Edit: The compiler is g++ 4.8 released a few days ago -- April 29th.
(I'm also wondering how to build just g++ when I download a gcc snapshot. It builds a bunch of Fortran and Java stuff that I'm not interested in.)
Advertisement
Someone on another newsgroup gave what seems to be a helpful explanation:

https://groups.google.com/forum/?fromgroups#!topic/comp.lang.c++/uVu6LEYO0pQ
You might want to compare the linker map files from the two versions. In my experience that usually tells you where size differences come from, as long as you can decipher the symbol names.

This topic is closed to new replies.

Advertisement