Re: Problem using struct with copy constructor with betterC
On Saturday, 6 November 2021 at 17:24:07 UTC, tchaloupka wrote: When built with `-betterC` switch (dmd as ldc2 works with it). I get just: ``` Error: `TypeInfo` cannot be used with -betterC ``` Well imagine getting this useful info in a large codebase :/ Looks like https://issues.dlang.org/show_bug.cgi?id=20715 BetterC is great, but a bit of a minefield to use. The blame might be more on copy constructors, here. This also fails: https://issues.dlang.org/show_bug.cgi?id=20365
Problem using struct with copy constructor with betterC
After a long fiddling with a code that won't compile I've got this test case: ```D struct Foo { this(ref return scope Foo rhs) {} ~this() {} } struct Bar { @disable this(this); Foo[2] foos; } extern (C) void main() {} ``` When built with `-betterC` switch (dmd as ldc2 works with it). I get just: ``` Error: `TypeInfo` cannot be used with -betterC ``` Well imagine getting this useful info in a large codebase :/ Anyway, I've traced the problem by custom built dmd using `printf` logging here: https://github.com/dlang/dmd/blob/a6f49dade85452d61d9ebcf329e2567ecacd5fab/src/dmd/e2ir.d#L2606 So it somehow tries to generate `_d_arrayctor` for the static array. I've tried to add `= void` to the array, but it doesn't help. Is it a bug (probably is) and are there any workaround for this? If I remove copy constructor or destructor form `Foo`, it compiles. But I need them there.. BetterC is great, but a bit of a minefield to use.