diff --git a/lib/IR/Value.cpp b/lib/IR/Value.cpp index d61b8e52ea8..35c241a608b 100644 --- a/lib/IR/Value.cpp +++ b/lib/IR/Value.cpp @@ -492,7 +492,8 @@ static bool isDereferenceablePointer(const Value *V, const DataLayout *DL, if (const BitCastInst* BC = dyn_cast(V)) { Type *STy = BC->getSrcTy()->getPointerElementType(), *DTy = BC->getDestTy()->getPointerElementType(); - if ((DL->getTypeStoreSize(STy) >= + if (STy->isSized() && DTy->isSized() && + (DL->getTypeStoreSize(STy) >= DL->getTypeStoreSize(DTy)) && (DL->getABITypeAlignment(STy) >= DL->getABITypeAlignment(DTy)))