Skip to content

[BUG] Integer overflow in tensor_t::View #1034

@deanljohnson

Description

@deanljohnson

Describe the Bug
Using tensor_t::View with a tensor containing more than INT_MAX elements causes an integer overflow.

To Reproduce

long long view_size = 3118080000;
auto t = matx::make_tensor<uint8_t>({view_size + 1});
auto v = t.View({view_size});

This will trigger an assert in the View function - "Total size of new tensor must not be larger than the original"

Additional Context

Tried to replicate the problem in Compiler Explorer. The initial value passed to std::accumulate being an integer literal seems to be the problem: https://godbolt.org/z/f4noePd8G

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