Skip to content

Commit

Permalink
Fixed crash with new operator and some union casts on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Jul 23, 2017
1 parent 3caa421 commit c1bd363
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ TypedValue* createUnionVariantCast(Compiler *c, TypedValue *valToCast, TypeNode
auto *alloca = c->builder.CreateAlloca(unionTy);

//but bitcast it the the current member
auto *castTo = c->builder.CreateBitCast(alloca, unionTy->getPointerTo());
auto *castTo = c->builder.CreateBitCast(alloca, taggedUnion->getType()->getPointerTo());
c->builder.CreateStore(taggedUnion, castTo);

//load the original alloca, not the bitcasted one
Expand Down Expand Up @@ -1574,7 +1574,7 @@ TypedValue* UnOpNode::compile(Compiler *c){

unsigned size = rhs->type->getSizeInBits(c) / 8;

Value *sizeVal = ConstantInt::get(*c->ctxt, APInt(32, size, true));
Value *sizeVal = ConstantInt::get(*c->ctxt, APInt(AN_USZ_SIZE, size, true));

Value *voidPtr = c->builder.CreateCall(mallocFn, sizeVal);
Type *ptrTy = rhs->getType()->getPointerTo();
Expand Down
4 changes: 2 additions & 2 deletions stdlib/prelude.an
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ fun puts: c8* str -> i32;
fun putchar: c8 char;
fun getchar: -> c8;
fun exit: i32 status;
fun malloc: u64 size -> void*;
fun realloc: void* ptr, u64 size -> void*;
fun malloc: usz size -> void*;
fun realloc: void* ptr, usz size -> void*;
fun free: void* mem;
fun memcpy: void* dest src, usz bytes -> void* /*dest*/;
fun system: c8* cmd -> i32;
Expand Down

0 comments on commit c1bd363

Please sign in to comment.