Bug 20715 – `Error: TypeInfo cannot be used with -betterC` for array of struct = void with copy constructor disabled

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-04-01T00:23:33Z
Last change time
2021-12-08T08:56:26Z
Keywords
betterC
Assigned to
No Owner
Creator
andy.pj.hanson

Comments

Comment #0 by andy.pj.hanson — 2020-04-01T00:23:33Z
``` extern(C) void main() { A a; } struct A { B[4] data = void; } struct B { @disable this(ref B b); ~this() {} } ``` Compile with `dmd -betterC app.d`. Testing with dmd v2.091.0. This code fails with: ``` Error: TypeInfo cannot be used with -betterC ``` There is no error location either!
Comment #1 by johan_forsberg_86 — 2021-11-07T00:33:07Z
When B is by ref A will have inout pure nothrow @nogc @safe this(ref inout(A) p) { this.data = p.data; return this; } B's destructor will not be nogc
Comment #2 by chalucha — 2021-11-07T10:03:20Z
One more test case for probably same issue: ```D struct Foo { this(ref return scope Foo rhs) {} ~this() {} } struct Bar { @disable this(this); Foo[2] foos = void; } extern (C) void main() {} ``` I've tracked this down to this line: https://github.com/dlang/dmd/blob/a6f49dade85452d61d9ebcf329e2567ecacd5fab/src/dmd/e2ir.d#L2606 So it has something to do with array copy constructor for `foos` array that it generates either though Bar has disabled copying? And missing location in error output is not helping at all to figure out where is the problem :(
Comment #3 by razvan.nitu1305 — 2021-12-08T08:56:26Z
This has been fixed thanks to transforming the hook into a template: https://github.com/dlang/dmd/pull/13116