Skip to content

Zero-sized array cannot be read from npy on Windows #88

@zhihaoy

Description

@zhihaoy

xtensor uses allocator to allocate xarray, but unlike new T[N] which does not return nullptr if N == 0, std::allocator<char>{}.allocate(m_n_bytes) may return nullptr. When it happens in MSVC STL runtime, the following code

    if (m_buffer == nullptr)
    {
        XTENSOR_THROW(std::runtime_error, "This npy_file has already been cast.");
    }

will deem a zero-sized array from npy file not exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No 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