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

Remove redundant moves in return statements #1090

Merged
merged 3 commits into from
Feb 10, 2022

Conversation

antoninbas
Copy link
Member

With recent g++ versions:

../include/bm/bm_sim/queueing.h:780:24: error: redundant move in return statement [-Werror=redundant-move]
780 | return std::move(fn);
| ^
../include/bm/bm_sim/queueing.h:780:24: note: remove 'std::move' call
cc1plus: all warnings being treated as error

While copy elision is not possible when retruning a function parameter,
if the other conditions for NVO are met, a move operation should be
used. The std::move doesn't cause the compiler to perform worse (unlike
for RVO), but it is redundant.

With recent g++ versions:

../include/bm/bm_sim/queueing.h:780:24: error: redundant move in return statement [-Werror=redundant-move]
  780 |     return std::move(fn);
      |                        ^
../include/bm/bm_sim/queueing.h:780:24: note: remove 'std::move' call
cc1plus: all warnings being treated as error

While copy elision is not possible when retruning a function parameter,
if the other conditions for NVO are met, a move operation should be
used. The std::move doesn't cause the compiler to perform worse (unlike
for RVO), but it is redundant.
@onf-cla-manager
Copy link

onf-cla-manager bot commented Feb 9, 2022

Hi @antoninbas, this is the ONF bot 🤖 I'm glad you want to contribute to our projects! However, before accepting your contribution, we need to ask you to sign a Contributor License Agreement (CLA). You can do it online, it will take only a few minutes:

✒️ 👉 https://cla.opennetworking.org

After signing, make sure to add your Github user ID antoninbas to the agreement.

For more information or help:"
https://wiki.opennetworking.org/x/BgCUI

When compiling code which depends on the generated Protobuf code for
P4Runtime.
Linking was broken after Ubuntu 20.04 / gcc 9 upgrade.
Not sure exactly why but removing some unused library dependencies can
resolve the issue ("undefined reference" for PI symbols).
Copy link
Member

@rst0git rst0git left a comment

Choose a reason for hiding this comment

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

LGTM

@antoninbas antoninbas merged commit a341309 into main Feb 10, 2022
@antoninbas antoninbas deleted the remove-redundant-moves-in-return-statements branch February 10, 2022 17:10
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.

2 participants