Reduced test case. Running ng.bat will reproduce link-failure.
application/x-zip-compressed
2613
Comments
Comment #0 by k.hara.pg — 2015-02-19T14:53:59Z
From: https://issues.dlang.org/show_bug.cgi?id=13167#c1
This code fails to compile with git-head, but succeeds with 2.066.1.
// test.d
import std.variant;
void main()
{
Variant a = true;
}
$ dmd test.d
DMD v2.067 DEBUG
OPTLINK (R) for Win32 Release 8.00.15
Copyright (C) Digital Mars 1989-2013 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test.obj(test)
Error 42: Symbol Undefined _D3std4conv11__T2toTAyaZ9__T2toTbZ2toFbZAya
--- errorlevel 1
This reduces to:
---
import std.conv;
struct S
{
ptrdiff_t function() fptr = &handler;
static ptrdiff_t handler()
{
static if (is(typeof(to!(string)(false))))
{
to!(string)(false);
}
return 0;
}
}
void main()
{
}
---
I don't think it has anything to do with 4335, but with emitting instantiations done during a typeof.
Comment #3 by bugzilla — 2015-03-05T05:37:29Z
This is crazy complicated.
What's happening is in TemplateInstance::needsCodegen(), the minst for to!string is set to std.bitmanip, which is not a root module, and so needsCodegen() says it should be in Phobos.lib. However, std.bitmanip never actually instantiates to!string, so it is not found in phobos.lib, and the link fails.
_D3std4conv11__T2toTAyaZ9__T2toTbZ2toFbZAya is to!string
So, to!string's minst is being set wrong.
The wrong value is set by this code in TemplateInstance::semantic():
---------------
// If the first instantiation was speculative, but this is not:
if (!inst->minst)
{
// Mark it is a non-speculative instantiation.
inst->minst = minst; <---- here
}
---------------
minst is set to std.bitmanip during the evaluation of std.bitmanip.FloatRep, which calls:
--------------
mixin(bitfields!(
uint, "fraction", 23,
ubyte, "exponent", 8,
bool, "sign", 1));
---------------
which winds up calling to!string at some point with sc->minst set to std.bitmanip.
I don't know why to!string is not emitted when Phobos is built.
Comment #4 by bugzilla — 2015-03-05T05:59:21Z
Hmm, a reference to:
_D3std4conv11__T2toTAyaZ9__T2toTbZ2toFbZAya
is generated, but there's a:
_D3std4conv11__T2toTAyaZ9__T2toTbZ2toFNaNfbZAya
in Phobos. The difference is the latter is Na (pure) and Nf (@safe).
So, somehow attribute inference is happening in the latter but not the former.