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

Mismatch between sizeof(Partio::ParticleIndex), sizeof(size_t), sizeof(int) #1482

Open
StefanBruens opened this issue Apr 8, 2022 · 0 comments

Comments

@StefanBruens
Copy link
Contributor

There is some assumption Partio uses size_t for its index type:

// RS::pointcloud_search takes size_t index array (because of the
// presumed use of Partio underneath), but OSL only has int, so we
// have to allocate and copy out. But, on architectures where int
// and size_t are the same, we can take a shortcut and let
// pointcloud_search fill in the array in place (assuming it's
// passed in the first place).

which is apparently wrong (for the last 12 years):
https://github.com/wdas/partio/blob/7cb3743c6e19c04ac049c05f8f81af2f24410ea3/src/lib/Partio.h#L55
typedef uint64_t ParticleIndex;

On 32 bit archs the compilation then fails due to:

static_assert (sizeof(size_t) == sizeof(Partio::ParticleIndex),
"Partio ParticleIndex should be the size of a size_t");
// FIXME -- if anybody cares about an architecture in which that is not
// the case, we can easily allocate local space to retrieve the indices,
// then copy them back to the caller's indices.

Wouldn't it be better change it to unsigned long* out_indices in RendererServices::pointcloud_search? (This may require a version bump for 64bit archs, but only if size_t != unsigned long. For 32bit archs, the current code does not work anyway). Dito for pointcloud_get.

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

No branches or pull requests

1 participant