Skip to content

GH-46310: [C++] Clean up -Wself-move warning #46311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented May 4, 2025

Rationale for this change

This cleans up code that generates compiler warnings and relies on undefined behavior

What changes are included in this PR?

Removal of self-move in the test suite

Are these changes tested?

Yes

Are there any user-facing changes?

No

Copy link

github-actions bot commented May 4, 2025

⚠️ GitHub issue #46310 has been automatically assigned in GitHub to PR creator.

@@ -412,11 +412,6 @@ class TestSmallStaticVector : public ::testing::Test {
IntVectorType<N> moved_moved_ints = std::move(moved_ints);
ASSERT_EQ(moved_moved_ints.size(), 5);
EXPECT_THAT(moved_moved_ints, ElementsAre(4, 5, 6, 7, 8));

// Move into itself
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cpp standard makes it so that standard library types that are self assigned like this exist in a valid but unspecified state, so I think testing the contents of this after a self move does not rely upon standard behavior.

See also https://stackoverflow.com/questions/68274999/is-it-allowed-to-self-move-an-object-in-c

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant