llvm-project
llvm-project copied to clipboard
[flang][runtime] Fix finalization case in assignment
There were two bugs in derived type array assignment processing that caused finalization to fail to occur for a test case. The first bug was an off-by-one error in address overlap testing that caused a false positive result for the test, whose left-hand side's allocatable's descriptor was immediately adjacent in memory to the right-hand side's array's data. The second bug was that in such overlap cases (even when legitimate) finalization would fail due to the LHS's descriptor having been copied to a temporary for deferred deallocation and then nullified.
This patch corrects the overlap analysis for this test, and also properly finalizes the LHS when overlap does exist. Some nearby dead code was removed to avoid future confusion.
Fixes https://github.com/llvm/llvm-project/issues/113375.