Conversation
f01d48e to
f521fd4
Compare
src/ip/Address.cc
Outdated
| Ip::Address::operator =(const Ip::Address &s) | ||
| { | ||
| memcpy(this, &s, sizeof(Ip::Address)); | ||
| memmove(&mSocketAddr_, &s.mSocketAddr_, sizeof(struct sockaddr_in6)); |
There was a problem hiding this comment.
If the default generated assignment operator works, please use that instead (and check whether we can remove an explicit copy constructor as well).
|
Do you mean converting those two to their C++11 " = default;" definitions? |
|
Yes, either that or removing them completely. If both solutions "work", pick whichever style you prefer for this use case (explicit =default or nothing explicit at all). |
f521fd4 to
223d7d6
Compare
rousskov
left a comment
There was a problem hiding this comment.
LGTM.
I polished the PR (and future commit) title and description to match the latest code version, to fix namespace spelling, and to disclaim knowledge of any specific bugs this fix addresses (AFAIK). Please feel free to polish further as needed and do not forget to use the updated title/description during the commit.
Most uses of memcpy should have been memove() to prevent potential copy-to-self bugs.
The default copy-construct and copy-assignment operators seem sufficient and under C++11 now seem to work.
223d7d6 to
9b9da2e
Compare
Explicit copy construction was slow and unnecessary. Explicit copy assignment mishandled self copying and was unnecessary. The remaining memcpy() calls mishandled self copying. There are no known cases of Ip::Address self copying.
Explicit copy construction was slow and unnecessary. Explicit copy assignment mishandled self copying and was unnecessary. The remaining memcpy() calls mishandled self copying. There are no known cases of Ip::Address self copying.
Explicit copy construction was slow and unnecessary. Explicit copy assignment mishandled self copying and was unnecessary. The remaining memcpy() calls mishandled self copying. There are no known cases of Ip::Address self copying.
Explicit copy construction was slow and unnecessary. Explicit copy assignment mishandled self copying and was unnecessary. The remaining memcpy() calls mishandled self copying. There are no known cases of Ip::Address self copying.
Explicit copy construction was slow and unnecessary. Explicit copy assignment mishandled self copying and was unnecessary. The remaining memcpy() calls mishandled self copying. There are no known cases of Ip::Address self copying.
Explicit copy construction was slow and unnecessary.
Explicit copy assignment mishandled self copying and was unnecessary.
The remaining memcpy() calls mishandled self copying.
There are no known cases of Ip::Address self copying.