Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong line number in traceback when multiple for loops #1003

Closed
nolta opened this issue Jul 3, 2012 · 1 comment
Closed

wrong line number in traceback when multiple for loops #1003

nolta opened this issue Jul 3, 2012 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@nolta
Copy link
Member

nolta commented Jul 3, 2012

In the following function, there's a bug on line 10:

$ cat for_loop_bug.jl
function for_loop_bug()
    n = 100
    x = zeros(n)

    for j = 1:n
        x[j] = j    # line 6
    end

    for j = 1:n
        x[j+1] = j  # line 10
    end
end

However the traceback reports the error as being on line 6:

$ julia -L for_loop_bug.jl
julia> for_loop_bug()
in for_loop_bug: arrayset: index out of range
 in for_loop_bug at test.jl:6
@JeffBezanson
Copy link
Member

Same cause as #922. I believe what happens is that with optimizations on, LLVM fuses the error-handling code for both array assignments, so when the error is thrown the instruction pointer always refers to the first assignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants