diff options
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 50fdcfd6eb..0b1632f234 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -946,7 +946,12 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { const QualType ElementType = Type->getAsPointerType()->getPointeeType(); uint64_t D = LHSValue.getLValueOffset() - RHSValue.getLValueOffset(); - D /= Info.Ctx.getTypeSize(ElementType) / 8; + uint64_t ElemSize; + if (ElementType->isVoidType() || ElementType->isFunctionType()) + ElemSize = 8; + else + ElemSize = Info.Ctx.getTypeSize(ElementType); + D /= ElemSize / 8; return Success(D, E); } |