[Issue 17623] Unexpected failure of an assertion on empty strings

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Jul 8 12:04:47 PDT 2017


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

Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec
          Component|dmd                         |dlang.org
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
This is a documentation bug; the code is correct.

A dynamic array in D is represented as a pointer (.ptr) and a length (.length).

>       string s = null;

s.length is 0 and s.ptr is null.

>       string t = "";

t.length is also 0, but t.ptr points towards a zero-length string literal. The
distinction is mainly that D string literals are zero-terminated, so that they
can be implicitly converted to a C string (const char*).

--


More information about the Digitalmars-d-bugs mailing list