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

Fix Result constructor #309

Merged
merged 2 commits into from
Jul 8, 2020

Conversation

msmk0
Copy link
Contributor

@msmk0 msmk0 commented Jul 7, 2020

Ensure correct rvalue reference forwarding and use default implementations where possible. Update the RiddersPropagator to use explicit return types. This fix some remaining compiler warning for #267.

@msmk0 msmk0 added Bug Something isn't working Component - Core Affects the Core module Impact - Minor Nuissance bug and/or affects only a single module labels Jul 7, 2020
@msmk0 msmk0 added this to the v0.28.00 milestone Jul 7, 2020
@msmk0 msmk0 requested a review from paulgessinger July 7, 2020 13:00
Copy link
Member

@paulgessinger paulgessinger left a comment

Choose a reason for hiding this comment

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

Other than the default -> delete fixes, I'm not sure I understand what is being 'fixed' here.

@msmk0 msmk0 added the 🚧 WIP Work-in-progress label Jul 7, 2020
@msmk0
Copy link
Contributor Author

msmk0 commented Jul 7, 2020

Other than the default -> delete fixes, I'm not sure I understand what is being 'fixed' here.

What triggers this are return std::move(...) statements in the RidderPropagator. Naively removing them leads to issues with implicitly defined/deleted Result constructors which this tries to solve. Have a look e.g. at this build output

@paulgessinger
Copy link
Member

paulgessinger commented Jul 7, 2020

Yeah sure, but it seems to me like this is behaving as expected. If you don't have the explicit move there, you get a copy. Just switching to the explicit constructor should do the trick I believe. I think this is a case where the compiler warning is simply wrong, the move is not redundant at all.

Result(Result<T, E>&& other) : m_var(std::move(other.m_var)){};
Result(Result<T, E>&&) = default;
Copy link
Member

Choose a reason for hiding this comment

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

So, I explicitly changed this from default to the explicit implementation. I don't quite remember the reason here anymore however. I vaguely remember this had to do with one of the clang builds.

Copy link
Member

Choose a reason for hiding this comment

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

Same for the move assignment, btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks exactly like the use case for defaulted constructors. There should be nothing special going on here. It might be that previous issues are related to the masked compiler warnings/errors that appeared with #267. Let me try to test this on top of #267 again.

@msmk0
Copy link
Contributor Author

msmk0 commented Jul 7, 2020

Yeah sure, but it seems to me like this is behaving as expected. If you don't have the explicit move there, you get a copy. Just switching to the explicit constructor should do the trick I believe. I think this is a case where the compiler warning is simply wrong, the move is not redundant at all.

I thought that the problem with std::move is that it might prevent copy-ellision in recent compilers. So it should never be used for local variables, as mentioned e.g. in ISOCPP F.48.

@paulgessinger
Copy link
Member

Yeah, if we get this warning, then we have to use the explicit constructors.

@codecov
Copy link

codecov bot commented Jul 7, 2020

Codecov Report

Merging #309 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #309      +/-   ##
==========================================
+ Coverage   48.32%   48.33%   +0.01%     
==========================================
  Files         323      323              
  Lines       16370    16370              
  Branches     7606     7604       -2     
==========================================
+ Hits         7911     7913       +2     
  Misses       3173     3173              
+ Partials     5286     5284       -2     
Impacted Files Coverage Δ
Core/include/Acts/Utilities/Result.hpp 79.59% <100.00%> (+4.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c69e51...d118b03. Read the comment docs.

@msmk0 msmk0 force-pushed the fix-result-constructors branch from 45720d6 to d118b03 Compare July 7, 2020 15:51
@msmk0
Copy link
Contributor Author

msmk0 commented Jul 7, 2020

@paulgessinger I reduced the scope of this PR. Only the minimal changes to fix the errors in #267 are retained.

@msmk0 msmk0 changed the title Fix Result constructors Fix Result constructor Jul 7, 2020
@msmk0 msmk0 removed the 🚧 WIP Work-in-progress label Jul 8, 2020
@msmk0
Copy link
Contributor Author

msmk0 commented Jul 8, 2020

@paulgessinger I would suggest that we merge this in without waiting for the fixed LCG CI builds.

@paulgessinger paulgessinger merged commit bae8fa5 into acts-project:master Jul 8, 2020
@msmk0 msmk0 deleted the fix-result-constructors branch July 9, 2020 13:59
paulgessinger pushed a commit to paulgessinger/acts that referenced this pull request Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Component - Core Affects the Core module Impact - Minor Nuissance bug and/or affects only a single module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants