On this page
B4105: actual parameters might overlap
Catalog status: active. Default severity: error. Stable name: alias-check. Family: Executable checks.
Two actuals of a call are components of the same variable, at least one of them for an out or in out parameter, and they are the same component when some indices are equal. The prover could not show that those indices differ (Ada RM 6.4.1): if they were equal, the result would depend on the order in which the parameters are copied back.
Example (Vada)
procedure Exchange (P : in out Path; I, J : Integer) is
begin
Swap (P (I), P (J)); -- the same point when I = J
end Exchange;Example (Varc)
pub fn exchange(p: inout Path, i, j: Integer) {
swap(&p[i], &p[j]); // the same point when i == j
}
What to do (Vada)
Make the indices provably different (a precondition I /= J, or a test before the call), or handle the equal case separately.
What to do (Varc)
Make the indices provably different (a precondition i != j, or a test before the call), or handle the equal case separately.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See executable checks, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.