[Issue 10920] template instantiation order dependent link failure problem

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Feb 5 01:54:10 PST 2015


https://issues.dlang.org/show_bug.cgi?id=10920

--- Comment #6 from Kenji Hara <k.hara.pg at gmail.com> ---
Sorry, the OP code was not correct. Precise test case is:

// foo.d
import bar;
void main() {
    BitArray ba;
    version(A) pragma(msg, typeof(ba.toString));

    FormatSpec!char fs;
    fs.func();
}

// bar.d
(same with in comment #0)


Command line:
$ dmd foo.d
--> OK

$ dmd -version=A foo.d
void()
OPTLINK (R) for Win32  Release 8.00.15
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
foo.obj(foo)
 Error 42: Symbol Undefined
_D3bar18__T10FormatSpecTaZ10FormatSpec4funcMFNaNbNiNfZv
--- errorlevel 1
--> NG

FormatSpec!char is instantiated in both main() and BitArray.toString(). When
-version=A specified, the first instantiation happens in toString(), and its
codegen is wrongly judged to be unnecessary. And the second instantiation is
ignored and link-failure occurs.

It's definitely an issue that depends on the semantic analysis order.

--


More information about the Digitalmars-d-bugs mailing list