[flang-commits] [flang] [flang][NFC] Document ALLOCATE/DEALLOCATE error semantics (PR #153027)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Mon Aug 11 07:54:29 PDT 2025


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/153027

This compiler stops an ALLOCATE/DEALLOCATE statement with multiple variables after encountering a recoverable error to avoid the risk of ambiguity in the case of multiple errors.  Document.

>From 134f7bd261a9f359a6d70c07fa5454588251f5cf Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 11 Aug 2025 07:49:31 -0700
Subject: [PATCH] [flang][NFC] Document ALLOCATE/DEALLOCATE error semantics

This compiler stops an ALLOCATE/DEALLOCATE statement with multiple
variables after encountering a recoverable error to avoid the
risk of ambiguity in the case of multiple errors.  Document.
---
 flang/docs/Extensions.md | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 11c67176df200..b20503e542fb8 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -900,6 +900,16 @@ print *, [(j,j=1,10)]
   since these default values need to be available to process incomplete
   structure constructors.
 
+* When an `ALLOCATE` or `DEALLOCATE` statement with multiple variables
+  has a `STAT=` specifier that allows the program to continue execution
+  after an error, the variables after the one with the error are left
+  deallocated (or allocated).  This interpretation allows the program to
+  identify the variable that encountered the problem while avoiding any
+  ambiguity in the case of multiple errors with distinct status codes.
+  Some compilers work differently; for maximum portability, avoid
+  `ALLOCATE` and `DEALLOCATE` statements with error recovery for
+  multiple variables.
+
 ## De Facto Standard Features
 
 * `EXTENDS_TYPE_OF()` returns `.TRUE.` if both of its arguments have the



More information about the flang-commits mailing list