From: Seo Sanghyeon Date: Wed, 26 Dec 2007 05:21:37 +0000 (+0000) Subject: Remove broken assert from CodeGen. Better check is done in Sema. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9bb947adc5641938bd72c247ff353721160eea70;p=clang Remove broken assert from CodeGen. Better check is done in Sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45358 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp index f20c43f522..81a0cedf4e 100644 --- a/CodeGen/CGExprScalar.cpp +++ b/CodeGen/CGExprScalar.cpp @@ -756,10 +756,7 @@ Value *ScalarExprEmitter::VisitBinSub(const BinaryOperator *E) { Value *RHS = Visit(E->getRHS()); const QualType LHSType = E->getLHS()->getType().getCanonicalType(); - const QualType RHSType = E->getRHS()->getType().getCanonicalType(); - assert(LHSType == RHSType && "Can't subtract different pointer types"); - - QualType LHSElementType = cast(LHSType)->getPointeeType(); + const QualType LHSElementType = cast(LHSType)->getPointeeType(); uint64_t ElementSize = CGF.getContext().getTypeSize(LHSElementType, SourceLocation()) / 8; diff --git a/test/CodeGen/pointer-arithmetic.c b/test/CodeGen/pointer-arithmetic.c index 6c644c6e06..6b4de91112 100644 --- a/test/CodeGen/pointer-arithmetic.c +++ b/test/CodeGen/pointer-arithmetic.c @@ -3,3 +3,5 @@ typedef int Int; int test1(int *a, Int *b) { return a - b; } + +int test2(const char *a, char *b) { return b - a; }