Skip to content

Performance tips recommend invalid use of @inbounds #54218

Closed
@LilithHafner

Description

@LilithHafner

https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-annotations (still broken on master)

includes

@noinline function inner(x, y)
    s = zero(eltype(x))
    for i=eachindex(x)
        @inbounds s += x[i]*y[i]
    end
    return s
end

which is UB because eachindex(x) may be out of bounds in y and @inbounds applies to all possible inputs to inner.

It should be eachindex(x, y). Making an issue instead of a PR to avoid conflict with #54211

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviordocsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions