[Bug libstdc++/60621] std::vector::emplace_back generates massively more code than push_back
marc at kdab dot com
gcc-bugzilla@gcc.gnu.org
Thu Jul 7 08:04:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60621
--- Comment #7 from marc at kdab dot com ---
Retesting with GCC 6.1, it looks better now:
$ g++ -O2 -o emplace-vs-push_back{.pb,.cpp}
$ g++ -O2 -o emplace-vs-push_back{.eb,.cpp} -DEMPLACE_BACK
$ strip emplace-vs-push_back.*
$ size emplace-vs-push_back.*
text data bss dec hex filename
4474 680 8 5162 142a emplace-vs-push_back.eb
4830 680 8 5518 158e emplace-vs-push_back.nt
5083 656 8 5747 1673 emplace-vs-push_back.pb
somewhat at the expense of pessimising push_back(), which used to be 500b
smaller in Comment 3, but at least the relation between emplace_back and
push_back, and between emplace_back(char[2], char[2], char[2]) and
emplace_back(std::string, std::string, std::string) are now as expected.
More information about the Gcc-bugs
mailing list