Skip to content

Fix bug of using GenericParamList after it's std::move'd #62656

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

valeriyvan
Copy link
Contributor

No description provided.

@@ -4504,6 +4504,17 @@ class DeclDeserializer {

outerParams = genericParams;
}
#ifndef NDEBUG
// Use outerParams before it will be moved with std::move(outerParams)
unsigned paramCount = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that crashing somewhere? I think that although this is makes when thinking about move semantics, this is not a problem in this case because outterParams is a pointer GenericParamList * and std::move of a pointer like trivial types such as int just defaults to copy so state of outerParams is not changed. The question would be why would we std::move a pointer, but I guess the answer is to match ctx.evaluator.cacheOutput signature with takes an r-value of request result value...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that crashing somewhere?

No, it's not.

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 question would be why would we std::move a pointer, but I guess the answer is to match ctx.evaluator.cacheOutput signature with takes an r-value of request result value...

That's common case why std::move is used.

What would you suggest? Should I close PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's wait for @CodaFi feedback :)

paramList != nullptr;
paramList = paramList->getOuterParameters()) {
paramCount += paramList->size();
}
assert(paramCount ==
Copy link
Contributor

Choose a reason for hiding this comment

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

This assert should be moved as well, since it's the reason we're computing paramCount here at all.

@CodaFi
Copy link
Contributor

CodaFi commented Dec 19, 2022

std::move here is just an rvalue cast. For a trivial type like GenericParamList *, there's no actual invalidation of the "underlying object". That said, I'm okay with moving this assert, but as I noted in the review you should move the assertion too.

@valeriyvan
Copy link
Contributor Author

std::move here is just an rvalue cast. For a trivial type like GenericParamList *, there's no actual invalidation of the "underlying object". That said, I'm okay with moving this assert, but as I noted in the review you should move the assertion too.

Should this PR be closed as irrelevant?

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.

3 participants