Thread overview
[Issue 21034] concatenation with a string literal could also append the trailing null
Dec 17, 2022
Iain Buclaw
Jul 14, 2023
Nick Treleaven
Jul 14, 2023
Salih Dincer
Jul 14, 2023
Basile-z
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=21034

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
July 14, 2023
https://issues.dlang.org/show_bug.cgi?id=21034

Nick Treleaven <nick@geany.org> changed:

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

--- Comment #1 from Nick Treleaven <nick@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.

--
July 14, 2023
https://issues.dlang.org/show_bug.cgi?id=21034

Salih Dincer <salihdb@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |salihdb@hotmail.com

--
July 14, 2023
https://issues.dlang.org/show_bug.cgi?id=21034

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
More simply:  the result of `LHS ~ RHS` should be guaranteed to be zero terminated when RHS is a StringExp.

--