Sorry for taking so long to reply, and thank you for your explanation.
I guess your second last sentence gets to the point where I have different expectations of what a compiler/interpreter or a running program should report as an error.
I have tried to cook up a small example of a bug that “works” in both Fortran 90 and Julia, and although it’s less than I had hoped (time is limited), the following might serve to demonstrate at least one issue.
The following short program with a bug is quite silly and useless but I hope it shows what I mean. If you compile this Fortran version:
program bd
implicit none
integer, parameter :: n=20
integer :: i,j=100
real, dimension(n) :: x,y
real :: dx=0.1
do i=1,n
x(i)=i*dx
y(j)=3*x(j)
end do
end program bd
with gfortran (v.11.0 in my case) using the flag -fbounds-check, you get this error:
At line 9 of file bugdemo.f90
Fortran runtime error: Index '100' of dimension 1 of array 'y' above upper bound of 20
Error termination. Backtrace:
#0 0x102857577
...
i.e., you are told which of the two arrays and which dimension of it has the problem. If you do something (almost) similar in Julia:
n=20
x=Array{Float64}(undef,n)
y=Array{Float64}(undef,5*n)
dx=0.1
j=100
for i in range(1,n,step=1)
x[i]=i*dx
y[j]=3*x[j]
end
the error message is much more verbose but less clear (to me at least) and doesn’t say which of the two arrays in the flawed line is the culprit:
BoundsError: attempt to access 20-element Vector{Float64} at index [100]
Stacktrace:
[1] getindex(A::Vector{Float64}, i1::Int64)
@ Base ./array.jl:801
[2] top-level scope
@ ./In[6]:8
[3] eval
@ ./boot.jl:360 [inlined]
[4] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1094
This is in spite of having given y
the length 100 in the Julia version to make the source of the error unambiguous; if I hadn’t done that, the error message would still be the same.
Of course, here debugging is not such a bit challenge, but you can easily imagine more crowded expressions where it becomes a pain to sort out this type of problem.
I don’t know if it is possible to enable Julia to provide this additional information without sacrificing performance. I should think that it must be feasible, because after all it must know which array has exceeded its bounds. Or is there already a means to do that?
At any rate, I hope this illustrates my point.