diff --git a/compiler/src/dmd/glue/todt.d b/compiler/src/dmd/glue/todt.d index 14f797eac16f..38c48e7cfd4d 100644 --- a/compiler/src/dmd/glue/todt.d +++ b/compiler/src/dmd/glue/todt.d @@ -1471,6 +1471,25 @@ private extern (C++) class TypeInfoDtVisitor : Visitor semanticTypeInfoMembers(sd); } + if (TemplateInstance ti = sd.isInstantiated()) + { + if (!ti.needsCodegen()) + { + if (sd.xeq && sd.xeq != StructDeclaration.xerreq) + toObjFile(sd.xeq, global.params.multiobj); + if (sd.xcmp && sd.xcmp != StructDeclaration.xerrcmp) + toObjFile(sd.xcmp, global.params.multiobj); + if (FuncDeclaration ftostr = search_toString(sd)) + toObjFile(ftostr, global.params.multiobj); + if (sd.xhash) + toObjFile(sd.xhash, global.params.multiobj); + if (sd.postblit) + toObjFile(sd.postblit, global.params.multiobj); + if (sd.dtor) + toObjFile(sd.dtor, global.params.multiobj); + } + } + /* Put out: * char[] mangledName; * void[] init; diff --git a/compiler/test/runnable/imports/test23731a.d b/compiler/test/runnable/imports/test23731a.d new file mode 100644 index 000000000000..c0386f30a8dc --- /dev/null +++ b/compiler/test/runnable/imports/test23731a.d @@ -0,0 +1,8 @@ +module imports.test23731a; + +struct Wrapper(T) +{ + T[] values; +} + +enum wrapperIntSize = Wrapper!int.sizeof; diff --git a/compiler/test/runnable/test23731.d b/compiler/test/runnable/test23731.d new file mode 100644 index 000000000000..8ed17ebb80f2 --- /dev/null +++ b/compiler/test/runnable/test23731.d @@ -0,0 +1,12 @@ +// https://github.com/dlang/dmd/issues/23731 + +import imports.test23731a; + +void main() +{ + auto ti = typeid(Wrapper!int); + auto a = Wrapper!int([1, 2]); + auto b = Wrapper!int([1, 2]); + assert(ti.equals(&a, &b)); + assert(ti.getHash(&a) == ti.getHash(&b)); +}