[flang-commits] [flang] [flang] Fix segfault in CSHIFT/EOSHIFT with dynamically optional DIM (PR #184431)
Sairudra More via flang-commits
flang-commits at lists.llvm.org
Wed Mar 4 12:00:24 PST 2026
================
@@ -489,6 +490,30 @@ mlir::Value HlfirCShiftLowering::lowerImpl(
if (!dim) {
// If DIM is not present, drop the last element which is a null Value.
operands.truncate(2);
+ } else if (loweredActuals[2] && loweredActuals[2]->handleDynamicOptional()) {
+ // DIM is a dynamically optional dummy argument.
+ // Use getIsPresent() directly (per eugeneepshteyn's review) rather than a
+ // 0-sentinel arithmetic check. Building our own fir.if ensures an
+ // explicitly-passed DIM=0 loads the actual value and reaches the runtime
+ // bounds check (per vzakhari's review), while an absent DIM defaults to 1
+ // per Fortran ยง16.9.68.
----------------
Saieiei wrote:
Sorry about this, removed special symbols
https://github.com/llvm/llvm-project/pull/184431
More information about the flang-commits
mailing list