Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

copybara-service[bot]
Copy link

Breaking change: Add a debug check that the target of CopyFrom is not a descendant of the source.

Previously, you were allowed to do the following:

MyMessage msg;
*msg.mutable_submessage() = msg;

However, this could leave the message in an inconsistent state in some contrived examples, and the order of operations is unclear and potentially compiler-dependent.

Instead, if you would like to do this, you should be explicit about the order of operations:

MyMessage msg;
MyMessage msg_copy = msg;
*msg.mutable_submessage() = std::move(msg_copy);

… a descendant of the source.

Previously, you were allowed to do the following:
```cc
MyMessage msg;
*msg.mutable_submessage() = msg;
```

However, this could leave the message in an inconsistent state in some contrived examples, and the order of operations is unclear and potentially compiler-dependent.

Instead, if you would like to do this, you should be explicit about the order of operations:
```cc
MyMessage msg;
MyMessage msg_copy = msg;
*msg.mutable_submessage() = std::move(msg_copy);
```

PiperOrigin-RevId: 820018061
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.