[Issue 4733] Possible bugs caused by dynamic arrays in boolean evaluation context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 29 14:00:06 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=4733

--- Comment #43 from Nick Treleaven <nick at geany.org> ---
kdevel adds detail that `if (arr.ptr)` and `if (arr)` are not the same! The
difference is significant for typeid(T).initializer, which has a null pointer
but non-zero length:
https://forum.dlang.org/post/yvhwvufbegsvupvvsdbe@forum.dlang.org

Note that `if (arr !is null)` is equivalent to `if (arr)`. Those check both the
.ptr and .length fields (i.e. `is null` means exactly the same as `is []`).

--


More information about the Digitalmars-d-bugs mailing list