Skip to content

Commit

Permalink
Merge pull request #4587 from 9rnsr/fix14425
Browse files Browse the repository at this point in the history
Issue 14425 - Indirect template instantiation within is expression causes missing linker symbols
  • Loading branch information
MartinNowak committed Apr 17, 2015
2 parents c7857c9 + 37da110 commit 95ff133
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/typinf.c
Expand Up @@ -407,7 +407,7 @@ class TypeInfoDtVisitor : public Visitor

void visit(TypeInfoStructDeclaration *d)
{
//printf("TypeInfoStructDeclaration::toDt() '%s'\n", toChars());
//printf("TypeInfoStructDeclaration::toDt() '%s'\n", d->toChars());
if (global.params.is64bit)
verifyStructSize(Type::typeinfostruct, 17 * Target::ptrsize);
else
Expand All @@ -424,6 +424,17 @@ class TypeInfoDtVisitor : public Visitor
if (!sd->members)
return;

if (TemplateInstance *ti = sd->isInstantiated())
{
/* Bugzilla 14425: TypeInfo_Struct would refer the members of
* struct (e.g. opEquals via xopEquals field), so if it's instantiated
* in speculative context, TypeInfo creation should also be
* stopped to avoid 'unresolved symbol' linker errors.
*/
if (!ti->needsCodegen() && !ti->minst)
return;
}

/* Put out:
* char[] name;
* void[] init;
Expand Down
9 changes: 9 additions & 0 deletions test/runnable/link14425.d
@@ -0,0 +1,9 @@
struct SFoo(I) { I i; }
struct SBar(I) { I i; }
static assert(is(SFoo!(SBar!string)));

class CFoo(I) { I i; }
class CBar(I) { I i; }
static assert(is(CFoo!(CBar!string)));

void main() {}

0 comments on commit 95ff133

Please sign in to comment.