Mercurial > projects > ldc
changeset 182:6526cf5bb2be trunk
[svn r198] Fixed: doing a length-changing cast of a full slice segfaulted. eg:
int[] ia = [1,2,3];
byte[] ba = cast(byte[])ia[];
author | lindquist |
---|---|
date | Wed, 07 May 2008 19:54:01 +0200 |
parents | ef4108f34db6 |
children | 3cdf4b0c75a1 |
files | gen/arrays.cpp |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/arrays.cpp Wed May 07 19:34:41 2008 +0200 +++ b/gen/arrays.cpp Wed May 07 19:54:01 2008 +0200 @@ -407,6 +407,7 @@ void DtoArrayCopySlices(DSliceValue* dst, DSliceValue* src) { + Logger::println("ArrayCopySlices"); const llvm::Type* arrty = getPtrToType(llvm::Type::Int8Ty); llvm::Value* sz1; @@ -428,6 +429,7 @@ void DtoArrayCopyToSlice(DSliceValue* dst, DValue* src) { + Logger::println("ArrayCopyToSlice"); const llvm::Type* arrty = getPtrToType(llvm::Type::Int8Ty); llvm::Value* sz1; @@ -786,6 +788,13 @@ ////////////////////////////////////////////////////////////////////////////////////////// llvm::Value* DtoArrayCastLength(llvm::Value* len, const llvm::Type* elemty, const llvm::Type* newelemty) { + Logger::println("DtoArrayCastLength"); + LOG_SCOPE; + + assert(len); + assert(elemty); + assert(newelemty); + size_t esz = getABITypeSize(elemty); size_t nsz = getABITypeSize(newelemty); if (esz == nsz) @@ -909,6 +918,9 @@ ////////////////////////////////////////////////////////////////////////////////////////// DValue* DtoCastArray(DValue* u, Type* to) { + Logger::println("DtoCastArray"); + LOG_SCOPE; + const llvm::Type* tolltype = DtoType(to); Type* totype = DtoDType(to); @@ -943,9 +955,9 @@ Logger::cout() << "from: " << *usl->ptr << " to: " << *ptrty << '\n'; rval = new llvm::BitCastInst(usl->ptr, ptrty, "tmp", gIR->scopebb()); if (fromtype->next->size() == totype->next->size()) - rval2 = usl->len; + rval2 = DtoArrayLen(usl); else - rval2 = DtoArrayCastLength(usl->len, ety, ptrty->getContainedType(0)); + rval2 = DtoArrayCastLength(DtoArrayLen(usl), ety, ptrty->getContainedType(0)); } else { llvm::Value* uval = u->getRVal();