DebugCheckArrayBounds¶
Checks at run time that the shapes in an array assignment conform.
Declaration¶
Syntax¶
DebugCheckArrayBounds(expr target, expr* components,
bool move_allocation)
Arguments¶
Argument |
Description |
|---|---|
|
the array being assigned to. |
|
the array operands of the right hand side, whose shapes must match |
|
|
Return values¶
None.
Description¶
This node is inserted by the array_op pass ahead of an array assignment when
bounds checking is enabled, and it is never produced by a frontend. It fails
at run time with a diagnostic naming the mismatching extents rather than
writing out of bounds. It is omitted when the extents of the target and of
all operands are compile-time constants and equal, since it cannot fail then.
The extents of a section are compile-time constants when the start, end and
stride of each of its subscript triplets are, as for a(:, i) with a of
constant bounds.
After it, every operand has the extent of the target in every dimension. The element references of the loop that implements the assignment rely on that and are marked in_bounds.
Each element of components must itself be an array: the check compares the
extents of the target against the extents of the operands the assignment
reads.
Examples¶
(DebugCheckArrayBounds
:target (Var
:v (SymbolRef 1 "a")
)
:components [
(Var
:v (SymbolRef 1 "b")
)
]
:move_allocation false
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"a" (Variable
:parent_symtab 1
:name "a"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
:memory_space :Global
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
"b" (Variable
:parent_symtab 1
:name "b"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
:memory_space :Global
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
}
)
:name "main"
:dependencies []
:body [
(DebugCheckArrayBounds
:target (Var
:v (SymbolRef 1 "a")
)
:components [
(Var
:v (SymbolRef 1 "b")
)
]
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "a")
)
:value (Var
:v (SymbolRef 1 "b")
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
)
]
:global_init nil
)
}
)
:items []
:global_init nil
)