Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: 64-bit FNV-1a path is never used due to undefined NPY_SIZEOF_SIZE_T #31034

@math-hiyoko

Description

@math-hiyoko

Describe the issue:

In the FNV-1a hash implementation, the 64-bit variant is never selected.

In the following code:

/*
* Compute a size_t FNV-1a hash of the given data
* This will use 32-bit or 64-bit hash depending on the size of size_t
*/
size_t
npy_fnv1a(const void *buf, size_t len)
{
#if NPY_SIZEOF_SIZE_T == 8
return (size_t)npy_fnv1a_64(buf, len, FNV1A_64_INIT);
#else /* NPY_SIZEOF_SIZE_T == 4 */
return (size_t)npy_fnv1a_32(buf, len, FNV1A_32_INIT);
#endif
}

the selection between 32-bit and 64-bit implementations depends on NPY_SIZEOF_SIZE_T. However, this macro does not appear to be defined, so the condition always falls back to the 32-bit version (npy_fnv1a_32).

As a result, even on 64-bit platforms, the 64-bit FNV-1a implementation is never used.

Since npy_intp is typically defined to match size_t, it may be more appropriate to use NPY_SIZEOF_INTP instead.

Reproduce the code example:

import numpy as np

# This issue is in the C implementation and cannot be directly reproduced
# from Python. It can be observed by inspecting the compiled code path
# or preprocessing output, where NPY_SIZEOF_SIZE_T is not defined and
# the 32-bit path is always selected.

Error message:

Python and NumPy Versions:

2.5.0.dev0+git20260319.b9ccff1
3.14.3 (main, Feb 3 2026, 15:32:20) [Clang 17.0.0 (clang-1700.6.3.2)]

Runtime Environment:

No response

How does this issue affect you or how did you find it:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions