[Issue 21034] concatenation with a string literal could also append the trailing null

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 14 13:22:46 UTC 2023


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

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #1 from Nick Treleaven <nick at geany.org> ---
The assert would fail anyway, because "0123" is immutable data. When you assign
"0" to s, that is different memory and cannot affect c.

Presumably this request is for:

    s = "0";
    s = s ~ "1";
    assert(s.ptr[2] == '\0');

That would cause unnecessary writes when appending a (short) string in a loop
and each null byte is not read.

--


More information about the Digitalmars-d-bugs mailing list