[flang-commits] [flang] [flang] Don't evaluate initializers for arrays with invalid rank (PR #171163)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Mon Dec 8 09:46:43 PST 2025
https://github.com/luporl created https://github.com/llvm/llvm-project/pull/171163
Evaluating initializers for arrays with a rank greater than the
maximum supported can make the compiler run out of memory.
Fixes #124488
>From 94e356240e48318a993a887e6c9bc3c58152742a Mon Sep 17 00:00:00 2001
From: Leandro Lupori <leandro.lupori at linaro.org>
Date: Mon, 8 Dec 2025 13:24:03 -0300
Subject: [PATCH] [flang] Don't evaluate initializers for arrays with invalid
rank
Evaluating initializers for arrays with a rank greater than the
maximum supported can make the compiler run out of memory.
Fixes #124488
---
flang/lib/Semantics/resolve-names.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 345a0e4e8ecce..c070546c6729d 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -9209,6 +9209,11 @@ bool DeclarationVisitor::CheckNonPointerInitialization(
void DeclarationVisitor::NonPointerInitialization(
const parser::Name &name, const parser::ConstantExpr &constExpr) {
+ // Don't evaluate initializers for arrays with a rank greater than the
+ // maximum supported, to avoid running out of memory.
+ if (name.symbol && name.symbol->Rank() > common::maxRank) {
+ return;
+ }
if (CheckNonPointerInitialization(
name, /*inLegacyDataInitialization=*/false)) {
Symbol &ultimate{name.symbol->GetUltimate()};
More information about the flang-commits
mailing list