mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-28 01:23:14 +01:00
Do not generate invalid memcpy() for struct self assignment.
This catches only the most trivial case, need to investigate this further. See GitHub #385.
This commit is contained in:
@@ -380,7 +380,14 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs, int op, bool canSkipPostblit)
|
||||
}
|
||||
|
||||
if (t->ty == Tstruct) {
|
||||
DtoAggrCopy(lhs->getLVal(), rhs->getRVal());
|
||||
llvm::Value* src = rhs->getRVal();
|
||||
llvm::Value* dst = lhs->getLVal();
|
||||
|
||||
// Check whether source and destination values are the same at compile
|
||||
// time as to not emit an invalid (overlapping) memcpy on trivial
|
||||
// struct self-assignments like 'A a; a = a;'.
|
||||
if (src != dst)
|
||||
DtoAggrCopy(dst, src);
|
||||
}
|
||||
else if (t->ty == Tarray) {
|
||||
// lhs is slice
|
||||
|
||||
Reference in New Issue
Block a user