llvm-project
llvm-project copied to clipboard
[Flang] DEALLOCATE(name-list, STAT=iostat), when some in name-list are allocated and some not, does not deallocate an allocated name that occurs after the first not-allocated name.
Partially successful DEALLOCATE with STAT= specifier should deallocate all names that can be deallocated.
The GNU and Intel compilers are also lazy like that.
Testcase
Program test_deallocate_some
Integer, Allocatable :: x1(:),x2(:),x3(:)
Integer::istat
Allocate (x1(10),x2(4),x3(5))
10 Deallocate(x2)
20 Deallocate(x1,x2,x3,stat=istat) ! istat non-zero because x2 is deallocated
If (istat==0) Print *, "bug STAT"
If (Allocated(x1)) Print *,"bug x1" ! x1 should have been deallocated at 20
If (Allocated(x2)) Print *,"bug x2" ! x2 was deallocated at 10
If (Allocated(x3)) Print *,"bug x3" ! x3 should have been deallocated att 20
End Program test_deallocate_some
This behavior is conformant (F'2023 subclause 9.7.4 paragraph 6, "If any other error condition occurs, each allocate-object has a processor-dependent status..." and is intentional.
Working as intended; closing bug.