Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang] Fix another crash from another fuzzer test. #122562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

klausler
Copy link
Contributor

Fixes #122045.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jan 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 11, 2025

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

Fixes #122045.


Full diff: https://github.com/llvm/llvm-project/pull/122562.diff

2 Files Affected:

  • (modified) flang/lib/Evaluate/shape.cpp (+1-1)
  • (added) flang/test/Semantics/bug122045.f90 (+6)
diff --git a/flang/lib/Evaluate/shape.cpp b/flang/lib/Evaluate/shape.cpp
index c7b2156a3de17a..37efe299e0f1ec 100644
--- a/flang/lib/Evaluate/shape.cpp
+++ b/flang/lib/Evaluate/shape.cpp
@@ -459,7 +459,7 @@ static MaybeExtentExpr GetNonNegativeExtent(
     } else {
       return ExtentExpr{*uval - *lval + 1};
     }
-  } else if (lbound && ubound &&
+  } else if (lbound && ubound && lbound->Rank() == 0 && ubound->Rank() == 0 &&
       (!invariantOnly ||
           (IsScopeInvariantExpr(*lbound) && IsScopeInvariantExpr(*ubound)))) {
     // Apply effective IDIM (MAX calculation with 0) so thet the
diff --git a/flang/test/Semantics/bug122045.f90 b/flang/test/Semantics/bug122045.f90
new file mode 100644
index 00000000000000..c68d2bbc142142
--- /dev/null
+++ b/flang/test/Semantics/bug122045.f90
@@ -0,0 +1,6 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! ERROR: Must be a scalar value, but is a rank-1 array
+! ERROR: Shape of initialized object 'a' must be constant
+complex:: a(n) = SUM([1])
+INTEGER, parameter :: n(2) = [2,2]
+end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[flang] fatal internal error: CHECK(lb.size() == shape_.size()) failed at flang/lib/Evaluate/constant.cpp(26)
2 participants