[Issue 9571] link error due to using unique ids in anonymous funcliteral

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 10 17:57:19 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9571


Martin Nowak <code at dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|linkage issue when using    |link error due to using
                   |separate compilation and    |unique ids in anonymous
                   |closures                    |funcliteral


--- Comment #7 from Martin Nowak <code at dawg.eu> 2013-04-10 17:57:16 PDT ---
cat > a.d << CODE
import b;

void main()
{
    foo();
}
CODE

cat > b.d << CODE
struct MapResult(alias fun)
{
    void bar()
    {
        fun(0);
    }
}

auto foo()
{
    version (all)
    {
        alias MapResult!(function(int c) => 0) M;
    }
    else
    {
        // works because it uses a named function literal
        auto func = function(int c) => 0;
        alias MapResult!(func) M;
    }
}
CODE

dmd -c a
dmd -c b
dmd a.o b.o
--------

During the compilation of a.d semantic3 is run on auto foo() and thus
an instantiation of MapResult!(...) is added to a.o.
The problem is that the anonymous funcliteral in a.o and the one in b.o used a
different unique id suffix.
Because semantic3 on MapResult.bar() is not run during a's compilation the
funcliteral is never referenced and missing from a.o.

nm a.o | grep funcliteral
U _D1b3fooFZv14__funcliteral5FNaNbNfiZi
nm b.o | grep funcliteral
T _D1b3fooFZv14__funcliteral1FNaNbNfiZi

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list