digitalmars.D.learn - Compiler complaining about ~ used on static array in nogc fn
- Shriramana Sharma (12/12) Jan 13 2016 Referring to: https://auto-tester.puremagic.com/show-run.ghtml?projectid...
- H. S. Teoh via Digitalmars-d-learn (8/22) Jan 13 2016 [...]
Referring to: https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid= 915054&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? --
Jan 13 2016
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= 915054&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.
Jan 13 2016