Skip to content

BUG: Clipping code assumes alignment % itemsize == 0 #26341

@seberg

Description

@seberg

The clipping code contains lines like:

        npy_intp is1 = steps[0] / sizeof(T), os1 = steps[3] / sizeof(T);

NumPy guarantees that ufunc data is aligned, but NumPy does not guarantee that alignment is equal to the itemsize. (in particularly, that is clearly not true for complex numbers)

As the quick fix: The code shouldn't use this pattern at all, I think.

But even if we ignore complex (because clipping and complex are weird), do platforms even guarantee that for the basic numerical types? Should code at least have a static_assert() or so if using such a pattern?

(xref gh-26280 because that is why I noticed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions