Skip to content

remove redundant copy operation. fix warning which can be interpreted as an error in some projects #3486

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

Merged
merged 7 commits into from
Nov 22, 2021

Conversation

Lishen1
Copy link
Contributor

@Lishen1 Lishen1 commented Nov 19, 2021

Description

Suggested changelog entry:

* Fix a rare warning about extra copy in an Eigen constructor. 

Copy link
Collaborator

@Skylion007 Skylion007 left a comment

Choose a reason for hiding this comment

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

You are missing a conditional here. the actual stride of the EigenConformable must be (0,0) if the negative stride boolean is not set (read the comment about bug http://eigen.tuxfamily.org/bz/show_bug.cgi?id=747). As this is implemented, I am worried it will break compatibility with old Eigen versions.

@Skylion007 Skylion007 self-requested a review November 19, 2021 16:09
Copy link
Collaborator

@Skylion007 Skylion007 left a comment

Choose a reason for hiding this comment

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

Yeah, older versions of Eigen will hit the static assert, so we need to make the Stride object is strictly positive for maximum backwards compatibility.

Comment on lines 84 to 85
stride{EigenRowMajor ? rstride > 0 ? rstride : 0 : cstride > 0 ? cstride : 0 /* outer stride */,
EigenRowMajor ? cstride > 0 ? cstride : 0 : rstride > 0 ? rstride : 0 /* inner stride */ } {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add parenthesis, please, I can't easily tell what's happening here.

// TODO: when Eigen bug #747 is fixed, remove the tests for non-negativity. http://eigen.tuxfamily.org/bz/show_bug.cgi?id=747
if (rstride < 0 || cstride < 0) {
negativestrides = true;
} else {
stride = {EigenRowMajor ? rstride : cstride /* outer stride */,
EigenRowMajor ? cstride : rstride /* inner stride */ };
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}

@henryiii henryiii merged commit 5d067e8 into pybind:master Nov 22, 2021
@github-actions github-actions bot added the needs changelog Possibly needs a changelog entry label Nov 22, 2021
@henryiii henryiii removed the needs changelog Possibly needs a changelog entry label Dec 21, 2021
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