www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Typepinfo is always generated for structs that contain structs that

reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
Type info is always generated for struct that contain structs 
that have an alias this. This was apparently done because of 
https://issues.dlang.org/show_bug.cgi?id=14948 and "fixed" in 
https://github.com/dlang/dmd/pull/5001 , see also 
https://github.com/dlang/dmd/blob/master/src/ddmd/clone.d#L655 
with the comment bugzilla link.

I have a couple of issues with this approach:
1) it builds typeinfo even if it is not used (the above issue 
involves using such a struct in an AA where it _is_ used, which 
is fine).
2) it does not respect -betterC, so there is no way to not have 
typeinfo which, IMO, makes -betterC rather useless.

Can we be more discerning with generation of typeinfo? i.e. 
generate it lazily and only if used, perhaps with weak linkage so 
end users can have it if they need it?
Jul 08
parent Rainer Schuetze <r.sagitario gmx.de> writes:
On 09.07.2017 05:31, Nicholas Wilson wrote:
 Type info is always generated for struct that contain structs that have 
 an alias this. This was apparently done because of 
 https://issues.dlang.org/show_bug.cgi?id=14948 and "fixed" in 
 https://github.com/dlang/dmd/pull/5001 , see also 
 https://github.com/dlang/dmd/blob/master/src/ddmd/clone.d#L655 with the 
 comment bugzilla link.
 
 I have a couple of issues with this approach:
 1) it builds typeinfo even if it is not used (the above issue involves 
 using such a struct in an AA where it _is_ used, which is fine).
 2) it does not respect -betterC, so there is no way to not have typeinfo 
 which, IMO, makes -betterC rather useless.
 
 Can we be more discerning with generation of typeinfo? i.e. generate it 
 lazily and only if used, perhaps with weak linkage so end users can have 
 it if they need it?
There is a pull request by Walter to generate the type info on demand: https://github.com/dlang/dmd/pull/6561 Unfortunately it seems to need a bit more work.
Jul 09