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

[registration] Remove deprecated method Registration::setInputCloud() from public API #4026

Merged
merged 3 commits into from
May 6, 2020

Conversation

kunaltyagi
Copy link
Member

Fixes #2724 by making compiler emit compile error if previously deprecated method is used

@kunaltyagi kunaltyagi added changelog: API break Meta-information for changelog generation module: registration changelog: fix Meta-information for changelog generation labels May 3, 2020
@kunaltyagi kunaltyagi added this to the pcl-1.11.0 milestone May 3, 2020
@kunaltyagi kunaltyagi marked this pull request as ready for review May 4, 2020 01:10
@kunaltyagi kunaltyagi added the needs: code review Specify why not closed/merged yet label May 4, 2020
@kunaltyagi
Copy link
Member Author

I'm not sure that this doesn't break behavior of downstream users in subtle ways.

Copy link
Member

@taketwo taketwo left a comment

Choose a reason for hiding this comment

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

I only see a potential of this breaking downstream project in a non-subtle way :)

@SergioRAgostinho SergioRAgostinho removed the needs: code review Specify why not closed/merged yet label May 4, 2020
@SergioRAgostinho
Copy link
Member

Merge at your convenience if the CI is green.

@kunaltyagi kunaltyagi added the needs: feedback Specify why not closed/merged yet label May 4, 2020
@taketwo
Copy link
Member

taketwo commented May 6, 2020

According to this, deleting a virtual function in deriving classes is not allowed by the standard. Changing visibility (as originally proposed by @kunaltyagi) is one of the listed workarounds. Another one is to add a static_assert to the override. Perhaps it would be a more user-friendly approach because we can explain the user what to do in the assertion message.

@kunaltyagi
Copy link
Member Author

I tested out a snippet in Godbolt and it didn't throw an error. Please show me the error in my ways 😆. A valid snippet would be very welcome indeed.

@SergioRAgostinho
Copy link
Member

Your example was broken. You cannot have a templated virtual function, so the function you declared was not overriding the original one. See the modified snippet https://godbolt.org/z/LdkanP

@kunaltyagi
Copy link
Member Author

static_assert(false,...) will fail immediately. The template is there to delay it from being evaluated by the compiler

See snippet

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented May 6, 2020

I took another look at the SO thread and the associated comments and they flag that the method can still be called from the base class, with the static_assert option. This happens because we're redefining the method in the derived class, not really overriding it.

Both solutions on the table (static assert and moving th private) suffer from the same, there's no way to prevent the call from a base pointer, because the base pointer has the method implemented.

Given the circumstances I vote to move it to private but keep the original implementation we deleted. There's no point in having a static deprecated warning because we'll never be able to delete the method properly, so we should just throw that warning at runtime.

Then again, if a user is gonna keep around a vector of base class pointers, I believe logically we would store Registration pointers, to invoke different registration methods. Not really PCLBase, because it has no functional value.

@kunaltyagi kunaltyagi added needs: code review Specify why not closed/merged yet and removed needs: feedback Specify why not closed/merged yet labels May 6, 2020
@kunaltyagi
Copy link
Member Author

PTAL. Updated to use private + runtime warning.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

if CI == green: 🚀

@kunaltyagi kunaltyagi merged commit 17e8333 into PointCloudLibrary:master May 6, 2020
@kunaltyagi kunaltyagi deleted the rm_setinputcloud branch May 6, 2020 13:45
@taketwo taketwo changed the title [registration] Removing deprecated method setInputCloud from public API [registration] Remove deprecated method Registration::setInputCloud() from public API May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: API break Meta-information for changelog generation changelog: fix Meta-information for changelog generation module: registration needs: code review Specify why not closed/merged yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removing deprecated methods changed behavior
3 participants