Index: lib/Sema/Sema.cpp =================================================================== --- lib/Sema/Sema.cpp +++ lib/Sema/Sema.cpp @@ -369,6 +369,13 @@ } } + // If we are casting pointers, we need to make sure we deal with address + // spaces properly. + if (Kind == CK_NoOp && ExprTy->isPointerType() && TypeTy->isPointerType() && + ExprTy->getPointeeType().getAddressSpace() != + TypeTy->getPointeeType().getAddressSpace()) + Kind = CK_AddressSpaceConversion; + return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK); }