[flang-commits] [flang] [Flang][OpenMP] Fix crash with character types in declare_reduction (PR #178038)

Krish Gupta via flang-commits flang-commits at lists.llvm.org
Wed Jan 28 03:22:00 PST 2026


================
@@ -89,37 +89,23 @@ static void createCleanupRegion(Fortran::lower::AbstractConverter &converter,
     mlir::Value arg = builder.loadIfRef(loc, block->getArgument(0));
     assert(mlir::isa<fir::BaseBoxType>(arg.getType()));
 
-    // Special handling for boxed character types - they need to use
-    // fir.box_addr instead of hlfir::genVariableRawAddress to avoid creating
-    // an hlfir::Entity from a value that doesn't satisfy isFortranEntity.
+    // Extract address from the box. For character types, use fir.box_addr
+    // directly to avoid creating an hlfir::Entity from a value that doesn't
+    // satisfy isFortranEntity (boxed characters may not be valid entities yet).
----------------
KrxGu wrote:

I removed the special character handling. After looking at the type definitions, `!fir.box<!fir.heap<!fir.char>>` IS a valid entity (BaseBoxType returns true), so `genVariableRawAddress` should work fine. I was being overly defensive without a clear reason. The code is much simpler now.

https://github.com/llvm/llvm-project/pull/178038


More information about the flang-commits mailing list