On Wednesday, 17 October 2018 at 16:50:36 UTC, Paul Backus wrote:
You can't append to an array in betterC code, because making space for the new elements requires allocating memory, and that uses the GC.

In theory, since you're only using the GC during CTFE, it shouldn't be a problem, but the D compiler doesn't *know* that's what you're doing, so it has to assume the function could be called at runtime--which would be an error.


The test2 is not build as source code, like you can use std.* in butterC ctfe function even it use GC.

for example you can use this function in betterC if it not build as source code(include from include path):

        string add_prefix(string exp) {
            string reg = "^" ~ exp;
            return reg ;
        }


the dynamic array append working for basic type but not for struct.

so I guess this is a dmd front bug.

Reply via email to