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: Unused Lamba Captures #3328

Open
dgovil opened this issue Sep 28, 2024 · 1 comment
Open

Compiler Warnings: Unused Lamba Captures #3328

dgovil opened this issue Sep 28, 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 Sep 28, 2024

Description of Issue

Clang (16 for me from Xcode 16, but will reproduce elsewhere) warns that several lambdas do not use their captured inputs.
This is potentially due to a capture difference between MSVC and Clang/GCC (see https://stackoverflow.com/questions/52416362/unused-lambda-capture-warning-when-capture-is-actually-used) but if that's the case it would be great to leave a comment , and potentially suppress the warnings.

Either way, I think it's a great first issue for someone to get to grips with building USD on Windows (where you can also get Clang) and get familiar with the codebase. I am building with python3 ./build_scripts/build_usd.py ~/Downloads/usd --build-variant debug --no-imaging -vvv.

Warnings replicated below:


[1327/4632] Building CXX object pxr/usd/sdf/CMakeFiles/sdf.dir/predicateExpression.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/usd/sdf/predicateExpression.cpp:163:34: warning: lambda capture 'opStack' is not used [-Wunused-lambda-capture]
  163 |     auto printLogic = [&opName, &opStack, &result](
      |                               ~~~^~~~~~~
1 warning generated.
/Users/dhruvgovil/Projects/usd/pxr/usd/sdf/predicateExpression.cpp:163:34: warning: lambda capture 'opStack' is not used [-Wunused-lambda-capture]
  163 |     auto printLogic = [&opName, &opStack, &result](
      |                               ~~~^~~~~~~
1 warning generated.


[1349/4632] Building CXX object pxr/usd/sdf/CMakeFiles/sdf.dir/pathExpression.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/usd/sdf/pathExpression.cpp:402:34: warning: lambda capture 'opStack' is not used [-Wunused-lambda-capture]
  402 |     auto printLogic = [&opName, &opStack, &result](
      |                               ~~~^~~~~~~
1 warning generated.
/Users/dhruvgovil/Projects/usd/pxr/usd/sdf/pathExpression.cpp:402:34: warning: lambda capture 'opStack' is not used [-Wunused-lambda-capture]
  402 |     auto printLogic = [&opName, &opStack, &result](
      |                               ~~~^~~~~~~
1 warning generated.

[1630/4632] Building CXX object pxr/usd/usdGeom/CMakeFiles/usdGeom.dir/basisCurves.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/usd/usdGeom/basisCurves.cpp:388:45: warning: lambda capture 'vstep' is not required to be captured for this use [-Wunused-lambda-capture]
  388 |                     segmentCounts.begin(), [vstep](int n) { return n / vstep; });
      |                                             ^~~~~
/Users/dhruvgovil/Projects/usd/pxr/usd/usdGeom/basisCurves.cpp:394:45: warning: lambda capture 'vstep' is not required to be captured for this use [-Wunused-lambda-capture]
  394 |                     segmentCounts.begin(), [vstep](int n) { return (n - 4) / vstep + 1; });
      |                                             ^~~~~
2 warnings generated.
/Users/dhruvgovil/Projects/usd/pxr/usd/usdGeom/basisCurves.cpp:388:45: warning: lambda capture 'vstep' is not required to be captured for this use [-Wunused-lambda-capture]
  388 |                     segmentCounts.begin(), [vstep](int n) { return n / vstep; });
      |                                             ^~~~~
/Users/dhruvgovil/Projects/usd/pxr/usd/usdGeom/basisCurves.cpp:394:45: warning: lambda capture 'vstep' is not required to be captured for this use [-Wunused-lambda-capture]
  394 |                     segmentCounts.begin(), [vstep](int n) { return (n - 4) / vstep + 1; });
      |                                             ^~~~~
2 warnings generated.

[2749/4632] Building CXX object pxr/imaging/hdSt/CMakeFiles/hdSt.dir/commandBuffer.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/imaging/hdSt/commandBuffer.cpp:529:26: warning: lambda capture 'N' is not required to be captured for this use [-Wunused-lambda-capture]
  529 |       [&visCounts, this, N](size_t start, size_t end) {
      |                        ~~^
1 warning generated.
/Users/dhruvgovil/Projects/usd/pxr/imaging/hdSt/commandBuffer.cpp:529:26: warning: lambda capture 'N' is not required to be captured for this use [-Wunused-lambda-capture]
  529 |       [&visCounts, this, N](size_t start, size_t end) {
      |                        ~~^
1 warning generated.

[3006/4632] Building CXX object pxr/imaging/hdx/CMakeFiles/hdx.dir/selectionTracker.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/imaging/hdx/selectionTracker.cpp:470:22: warning: lambda capture 'N' is not required to be captured for this use [-Wunused-lambda-capture]
  470 |        [&ids, index, N, &selectedPrims](size_t begin, size_t end) mutable {
      |                    ~~^
1 warning generated.
/Users/dhruvgovil/Projects/usd/pxr/imaging/hdx/selectionTracker.cpp:470:22: warning: lambda capture 'N' is not required to be captured for this use [-Wunused-lambda-capture]
  470 |        [&ids, index, N, &selectedPrims](size_t begin, size_t end) mutable {
      |                    ~~^
1 warning generated.

[3463/4632] Building CXX object pxr/usd/usdSkel/CMakeFiles/usdSkel.dir/bakeSkinning.cpp.o
/Users/dhruvgovil/Projects/usd/pxr/usd/usdSkel/bakeSkinning.cpp:2436:29: warning: lambda capture 'parms' is not used [-Wunused-lambda-capture]
 2436 |                 [time, ti, &parms, &skinningAdapters, &bytesStoredPerLayer]
      |                          ~~~^~~~~
1 warning generated.
/Users/dhruvgovil/Projects/usd/pxr/usd/usdSkel/bakeSkinning.cpp:2436:29: warning: lambda capture 'parms' is not used [-Wunused-lambda-capture]
 2436 |                 [time, ti, &parms, &skinningAdapters, &bytesStoredPerLayer]
      |                          ~~~^~~~~
1 warning generated.
@dgovil dgovil added the good first issue Indicates a good issue for first-time contributors label Sep 28, 2024
@jesschimein
Copy link

Filed as internal issue #USD-10212

@dgovil dgovil changed the title Compiler Warnings: Unused Lamba Cpatures Compiler Warnings: Unused Lamba Captures Oct 1, 2024
@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