Skip to content

Array::from_shape_vec panics on shapes that are too big for usize on the platform #852

@bluss

Description

@bluss

The test deny_wraparound_from_vec fails on 32-bit:

thread 'deny_wraparound_from_vec' panicked at 'attempt to multiply with overflow', ndarray/src/dimension/dimension_trait.rs:137:17

The following code panics for wraparound in multiplication:

let five_large = Array::from_shape_vec((3, 7, 29, 36760123, 823996703), five.clone());

The reason is that we use default_strides for this shape, before doing the size check of the shape. In this case, the strides wrap around (so this shape is clearly too big for the current platform).

The expected result is that Array::from_shape_vec should return an error for this input. Any methods in ShapeBuilder that may panic could need to be documented that way.

We should add a ci configuration that tests a 32-bit target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions