[flang-commits] [flang] 6772966 - [flang] Fix dereference of std::optional with no value

Jay Foad via flang-commits flang-commits at lists.llvm.org
Thu Jan 26 09:52:36 PST 2023


Author: Jay Foad
Date: 2023-01-26T17:36:44Z
New Revision: 6772966dcdf5175c517832c1b2352b4fcd1d6b16

URL: https://github.com/llvm/llvm-project/commit/6772966dcdf5175c517832c1b2352b4fcd1d6b16
DIFF: https://github.com/llvm/llvm-project/commit/6772966dcdf5175c517832c1b2352b4fcd1d6b16.diff

LOG: [flang] Fix dereference of std::optional with no value

Differential Revision: https://reviews.llvm.org/D142648

Added: 
    

Modified: 
    flang/lib/Optimizer/Builder/Character.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Optimizer/Builder/Character.cpp b/flang/lib/Optimizer/Builder/Character.cpp
index de4a5579620da..aa455e768a086 100644
--- a/flang/lib/Optimizer/Builder/Character.cpp
+++ b/flang/lib/Optimizer/Builder/Character.cpp
@@ -422,7 +422,7 @@ void fir::factory::CharacterExprHelper::createAssign(
       (lhsCstLen && rhsCstLen && *lhsCstLen == *rhsCstLen) ||
       (rhs.getLen() == lhs.getLen());
 
-  if (compileTimeSameLength && *lhsCstLen == 1) {
+  if (compileTimeSameLength && lhsCstLen && *lhsCstLen == 1) {
     createLengthOneAssign(lhs, rhs);
     return;
   }


        


More information about the flang-commits mailing list