diff --git a/flang/lib/Optimizer/Builder/Character.cpp b/flang/lib/Optimizer/Builder/Character.cpp --- a/flang/lib/Optimizer/Builder/Character.cpp +++ b/flang/lib/Optimizer/Builder/Character.cpp @@ -422,7 +422,7 @@ (lhsCstLen && rhsCstLen && *lhsCstLen == *rhsCstLen) || (rhs.getLen() == lhs.getLen()); - if (compileTimeSameLength && *lhsCstLen == 1) { + if (compileTimeSameLength && lhsCstLen && *lhsCstLen == 1) { createLengthOneAssign(lhs, rhs); return; }