Skip to content

Avoid nonnull warning in rvalue construction of TfSmallVector without local storage#4036

Open
nvmkuruc wants to merge 1 commit intoPixarAnimationStudios:devfrom
nvmkuruc:small-vector-move-no-local
Open

Avoid nonnull warning in rvalue construction of TfSmallVector without local storage#4036
nvmkuruc wants to merge 1 commit intoPixarAnimationStudios:devfrom
nvmkuruc:small-vector-move-no-local

Conversation

@nvmkuruc
Copy link
Copy Markdown
Collaborator

@nvmkuruc nvmkuruc commented Apr 10, 2026

Description of Change(s)

TfSmallVector supports instantiations with no local storage (the capacity template argument set to 0). These are utilized in pxr/exec.

The TfSmallVector move constructor assumes is that if the sizes of the local storage and the rvalue parameter are the same, the rvalue's data can be moved into the constructing object's local storage. However, if the local storage size is 0, the _UninitializedMove tries to move an empty range into non-existent local storage. In newer versions of GCC, this causes a warning.

# Truncated stack trace
inlined from ‘static Iterator pxrInternal_v0_26_5__pxrReserved__::TfSmallVectorBase::_UninitializedMove(Iterator, Iterator, Iterator) [with Iterator = pxrInternal_v0_26_5__pxrReserved__::GfQuatd*]’ at pxr/base/tf/smallVector.h:84:39,
inlined from ‘pxrInternal_v0_26_5__pxrReserved__::TfSmallVector<T, N>::TfSmallVector(pxrInternal_v0_26_5__pxrReserved__::TfSmallVector<T, N>&&) [with T = pxrInternal_v0_26_5__pxrReserved__::GfQuatd; unsigned int N = 0]’ at pxr/base/tf/smallVector.h:245:35
...
error: argument 1 null where non-null expected [-Werror=nonnull]

This change introduces a constexpr guard to only apply the move if local storage is available.

With this change, the following build command should build without warnings or errors in GCC 13.

python3 build_scripts/build_usd.py ../inst/usd-strict --no-imaging --no-examples --no-materialx  --build-args USD,'-DPXR_STRICT_BUILD_MODE=ON -DCMAKE_CXX_FLAGS="-Wno-array-bounds -Wno-uninitialized"' -vv --tests

Link to proposal (if applicable)

Fixes Issue(s)

Checklist

@sunyab
Copy link
Copy Markdown
Contributor

sunyab commented Apr 10, 2026

Filed as internal issue #USD-12078

(This is an automated message. See here for more information.)

@nvmkuruc nvmkuruc force-pushed the small-vector-move-no-local branch from 2abb85b to 3fc625f Compare April 10, 2026 23:05
@nvmkuruc nvmkuruc changed the title Avoid warning with rvalue construction without local storage Avoid nonnull warning in TfSmallVector rvalue construction without local storage Apr 10, 2026
@nvmkuruc nvmkuruc changed the title Avoid nonnull warning in TfSmallVector rvalue construction without local storage Avoid nonnull warning in rvalue construction of TfSmallVector without local storage Apr 10, 2026
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