betterC generate dynamic array throw Error: TypeInfo cannot be used with -betterC
learnfirst1
learnfirst1 at gmail.com
Thu Oct 18 00:13:55 UTC 2018
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.
More information about the Digitalmars-d-learn
mailing list