Skip to content
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

Fixes #1984

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open

Fixes #1984

wants to merge 11 commits into from

Conversation

varunagrawal
Copy link
Collaborator

@varunagrawal varunagrawal commented Jan 20, 2025

Fixes #1738 and #1982.

Additionally, replaced [=], which captures by copy in lambda expressions, by [&] which captures by reference.

I updated the CI to check for lower and upper bounds of versions, with the assumption that everything in between is supported. Additionally, if the no_boost flag is set, I updated the CI to not install Boost so that we can better capture issues with Boost being optional.

Update: Also fixed a bug from #1444 where while the $GITHUB_ENV variable is updated for the No-Boost case, it isn't actually used anywhere.

cc: @Gold856

@varunagrawal varunagrawal requested a review from dellaert January 20, 2025 07:36
@varunagrawal varunagrawal self-assigned this Jan 20, 2025
@thorstink
Copy link
Contributor

thorstink commented Jan 20, 2025

Maybe nitpicking, by when trying cpp20, this this deprecation warning now also pops up; I think this is the only one as I was able to compile using cpp20 before these constraint-features got merged. Not sure if it makes sense to add a cpp20 pipeline, AFAIK it would compile except for this.

18.23 /tmp/gtsam/gtsam-0959bfef5c7e206a78e38ded84c4397940ea80ac/gtsam/constrained/InequalityPenaltyFunction.cpp: In lambda function:
18.23 /tmp/gtsam/gtsam-0959bfef5c7e206a78e38ded84c4397940ea80ac/gtsam/constrained/InequalityPenaltyFunction.cpp:25:10: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated]
18.23    25 |   return [=](const double& x, OptionalJacobian<1, 1> H = {}) -> double { return (*this)(x, H); };

@dellaert
Copy link
Member

Maybe nitpicking, by when trying cpp20, this this deprecation warning now also pops up; I think this is the only one as I was able to compile using cpp20 before these constraint-features got merged. Not sure if it makes sense to add a cpp20 pipeline, AFAIK it would compile except for this.

18.23 /tmp/gtsam/gtsam-0959bfef5c7e206a78e38ded84c4397940ea80ac/gtsam/constrained/InequalityPenaltyFunction.cpp: In lambda function:
18.23 /tmp/gtsam/gtsam-0959bfef5c7e206a78e38ded84c4397940ea80ac/gtsam/constrained/InequalityPenaltyFunction.cpp:25:10: error: implicit capture of 'this' via '[=]' is deprecated in C++20 [-Werror=deprecated]
18.23    25 |   return [=](const double& x, OptionalJacobian<1, 1> H = {}) -> double { return (*this)(x, H); };

@varunagrawal the fix is easy: just replace that line with

return [this](const double& x, OptionalJacobian<1, 1> H = {}) { return this->operator()(x, H); };

BTW, there are some other occurrences of [] in an example and in some tests. In these (few) cases just narrowing the scope (e.g. [=] -> [nearZero] in testSO3.cpp) should resolve this.

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

Maybe also merge in develop after #1983
I'll approve after suggested [=] fixes and CI changes, please re-request a review from me then.

@varunagrawal varunagrawal requested a review from dellaert January 20, 2025 15:29
Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

Awesome, just some doubt about removing default copy constructor.

@@ -60,8 +60,6 @@ class TestOptionalStruct {
TestOptionalStruct() = default;
TestOptionalStruct(const int& opt)
: opt(opt) {}
// A copy constructor is needed for serialization
TestOptionalStruct(const TestOptionalStruct& other) = default;
Copy link
Member

Choose a reason for hiding this comment

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

I think I just reviewed a PR that added these?

Copy link
Collaborator Author

@varunagrawal varunagrawal Jan 20, 2025

Choose a reason for hiding this comment

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

This copy constructor was added 2 years ago.

I am currently getting an error because of this

error: definition of implicit copy assignment operator for 'TestOptionalStruct' is deprecated because it has a user-declared copy constructor [-Werror,-Wdeprecated-copy]

Seems to be that using the compiler generated copy-constructors and using the = default constructor no longer gel well together.

@dellaert
Copy link
Member

Seems like not installing BOOST already found an issue with our cmake. Happy for this PR to omit that change and surface it in an issue.

@varunagrawal
Copy link
Collaborator Author

Seems like not installing BOOST already found an issue with our cmake. Happy for this PR to omit that change and surface it in an issue.

Ah I was a bit too quick for you. Already fixed it here.

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.

Constrained depends on Boost even when building GTSAM without Boost Build failure for tests with GCC 13
3 participants