diff --git a/flang/lib/Evaluate/characteristics.cpp b/flang/lib/Evaluate/characteristics.cpp --- a/flang/lib/Evaluate/characteristics.cpp +++ b/flang/lib/Evaluate/characteristics.cpp @@ -788,7 +788,10 @@ return false; } else if (const auto *ifaceTypeShape{std::get_if(&u)}) { if (const auto *actualTypeShape{std::get_if(&actual.u)}) { - if (ifaceTypeShape->shape() != actualTypeShape->shape()) { + if (ifaceTypeShape->Rank() != actualTypeShape->Rank()) { + return false; + } else if (!attrs.test(Attr::Allocatable) && !attrs.test(Attr::Pointer) && + ifaceTypeShape->shape() != actualTypeShape->shape()) { return false; } else { return ifaceTypeShape->type().IsTkCompatibleWith(