From 8935b50d1b117a5bee6bf570999e4b263f124b03 Mon Sep 17 00:00:00 2001 From: Peter Klausler Date: Tue, 12 Aug 2025 12:38:05 -0700 Subject: [PATCH] [flang][runtime][NFC] Add a comment to intrinsic assignment Add a comment explaining why intrinsic derived type assignment unconditionally deallocates all allocated allocatable subobject components of the left-hand side variable, so that I won't forget the reasoning here the next time this comes into question. --- flang-rt/lib/runtime/assign.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flang-rt/lib/runtime/assign.cpp b/flang-rt/lib/runtime/assign.cpp index 7cf4147a94a95..6aeb103208785 100644 --- a/flang-rt/lib/runtime/assign.cpp +++ b/flang-rt/lib/runtime/assign.cpp @@ -369,6 +369,9 @@ RT_API_ATTRS int AssignTicket::Begin(WorkQueue &workQueue) { return status; } } else if (!toDerived_->noDestructionNeeded()) { + // F'2023 9.7.3.2 p7: "When an intrinsic assignment statement (10.2.1.3) + // is executed, any noncoarray allocated allocatable subobject of the + // variable is deallocated before the assignment takes place." if (int status{ workQueue.BeginDestroy(to_, *toDerived_, /*finalize=*/false)}; status != StatOk && status != StatContinue) {