On Wed, Jan 13, 2016 at 10:23:17PM +0530, Shriramana Sharma via 
Digitalmars-d-learn wrote:
> Referring to: 
> https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid=1915054&isPull=true,
>  the lines in question are 
> phobos/std/utf.d (66, 67):
> 
>         UnsignedStringBuf buf = void;
>         msg ~= " (at index " ~ unsignedToTempString(index, buf, 10) ~ ")";
> 
> rgrepping through the druntime and phobos sources for this symbol
> UnsignedStringBuf I found:
> 
> ./druntime/src/core/internal/string.d:16:alias UnsignedStringBuf = char[20];
> 
> So if it's a static array, then it has nothing to do with the GC, and
> appending will not use the GC, right? So why is the compiler
> complaining that I cannot use ~ inside a @nogc function?
[...]

Even though unsignedToTempString() uses a static array, `msg` is a
string, so appending to it using ~ or ~= may cause reallocation. That
violates @nogc.


T

-- 
Computers shouldn't beep through the keyhole.

Reply via email to