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

Compiler Warnings: Explicit moves to self #3341

Open
dgovil opened this issue Oct 2, 2024 · 1 comment
Open

Compiler Warnings: Explicit moves to self #3341

dgovil opened this issue Oct 2, 2024 · 1 comment
Labels
good first issue Indicates a good issue for first-time contributors help wanted Indicates an issue where help and/or a pull request from the community would be very welcome

Comments

@dgovil
Copy link
Collaborator

dgovil commented Oct 2, 2024

Description of Issue

Clang raises a few areas where we are moving the same variable into itself. It would be a good first task for someone new to the project to see if these can be cleaned up or annotated

According to the Clang doc changes, they suggest

The clang release notes suggests:
---
If you are doing such an assignment intentionally, e.g. in a unit test for
a data structure, the warning can be suppressed by adding ``*&`` to the
right-hand side or casting it to the appropriate reference type.
---

Firefox have a similar discussion here https://bugzilla.mozilla.org/show_bug.cgi?id=1453610

I am building with Clang 16 from Xcode 16 with python3 ./build_scripts/build_usd.py ~/Downloads/usd --build-variant debug --no-imaging -vvv but this should reproduce with other compilers. The warnings are reproduced below:

[3566/4632] Building CXX object pxr/base/tf/CMakeFiles/testTf.dir/testenv/delegatedCountPtr.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/base/tf/testenv/delegatedCountPtr.cpp:172:13: warning: explicitly moving variable of type 'TfTestDelegatedCountPtr' (aka 'TfDelegatedCountPtr<RefCountedValue>') to itself [-Wself-move]
  172 |     adopted = std::move(adopted);
      |     ~~~~~~~ ^           ~~~~~~~
/Users/dhruvgovil/Projects/usd/pxr/base/tf/testenv/delegatedCountPtr.cpp:228:10: warning: explicitly assigning value of variable of type 'TfDelegatedCountPtr<RefCountedValue>' to itself [-Wself-assign-overloaded]
  228 |     made = made;
      |     ~~~~ ^ ~~~~
2 warnings generated.
/Users/dhruvgovil/Projects/usd/pxr/base/tf/testenv/delegatedCountPtr.cpp:172:13: warning: explicitly moving variable of type 'TfTestDelegatedCountPtr' (aka 'TfDelegatedCountPtr<RefCountedValue>') to itself [-Wself-move]
  172 |     adopted = std::move(adopted);
      |     ~~~~~~~ ^           ~~~~~~~
/Users/dhruvgovil/Projects/usd/pxr/base/tf/testenv/delegatedCountPtr.cpp:228:10: warning: explicitly assigning value of variable of type 'TfDelegatedCountPtr<RefCountedValue>' to itself [-Wself-assign-overloaded]
  228 |     made = made;
      |     ~~~~ ^ ~~~~
2 warnings generated.
@dgovil dgovil added the good first issue Indicates a good issue for first-time contributors label Oct 2, 2024
@jesschimein
Copy link

Filed as internal issue #USD-10238

@pixar-oss pixar-oss added the help wanted Indicates an issue where help and/or a pull request from the community would be very welcome label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Indicates a good issue for first-time contributors help wanted Indicates an issue where help and/or a pull request from the community would be very welcome
Projects
None yet
Development

No branches or pull requests

3 participants