Open kmr-srbh opened 5 months ago
In GFortran you have to use -fcheck=all
to enable array bounds checking.
In LFortran we also need to add array bounds checking in Debug mode. We'll do that after beta.
Finally, this use case of declaring array dimension using a global variable is a very corner case that I would not worry about it right now. Eventually in Debug mode all these cases will be checked.
Both GFortran and LFortran print random garbage values when the array dimension is larger than the actual stored values in an array.
GFortran allows this behavior, but should we also allow it? Can we not restrict the values to those actually present in the array, here,
1 2 3 4 5 6
and avoid these garbage values?The example above uses an array in a subroutine for the demonstration purpose. Variables other than
parameter
annotated constants should not be allowed to set the dimension of arrays in aprogram
scope due to #4126.