Skip to content

array_iter_base::advance Should Take a ssize_t #267

@nhusung

Description

@nhusung

I recently had an issue with Adiar, which uses TPIE. Running the example with clang’s undefined behavior sanitizer revealed unsigned overflows when computing offsets in the following method:

void advance(size_t n) {if (forward) elm += n; else elm -= n;}

The overflow happens e.g. in case of n = (size_t) -1. Using ssize_t (i.e. the signed version of size_t) as argument seems to fix the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions