mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
Fixed dynamic array -> boolean. does (arr.ptr !is null) now instead of (arr.length != 0)
This commit is contained in:
parent
4d610bcd7e
commit
ed7dd481e5
2 changed files with 9 additions and 2 deletions
|
@ -1562,8 +1562,10 @@ LLValue* DtoBoolean(Loc& loc, DValue* dval)
|
||||||
// dynamic array
|
// dynamic array
|
||||||
else if (ty == Tarray)
|
else if (ty == Tarray)
|
||||||
{
|
{
|
||||||
// return (arr.length != 0)
|
// return (arr.ptr !is null)
|
||||||
return gIR->ir->CreateICmpNE(DtoArrayLen(dval), DtoConstSize_t(0), "tmp");
|
LLValue* ptr = DtoArrayPtr(dval);
|
||||||
|
LLConstant* nul = getNullPtr(ptr->getType());
|
||||||
|
return gIR->ir->CreateICmpNE(ptr, nul, "tmp");
|
||||||
}
|
}
|
||||||
// delegate
|
// delegate
|
||||||
else if (ty == Tdelegate)
|
else if (ty == Tdelegate)
|
||||||
|
|
5
tests/mini/strings2.d
Normal file
5
tests/mini/strings2.d
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
char[] s = "";
|
||||||
|
assert(s);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue