www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12754] New: MAC link error for template to static value

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

          Issue ID: 12754
           Summary: MAC link error for template to static value
           Product: D
           Version: D2
          Hardware: All
                OS: Mac OS X
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: monarchdodra gmail.com

Currently blocking
https://github.com/D-Programming-Language/phobos/pull/2172/files#r12711667

Reproducible only on MAC. Requires 2 "library" files, and a "client" file.

We'll call the library "foo":

//-----
//foo/traits.d
module foo.traits;

template lvalueInit(T)
{
    static lvalueInit = immutable(T).init;
}
//-----

//-----
//foo/file.d
module foo.file;

import foo.traits;

struct Impl
{

}

struct F
{
    Impl i;
    this(int)
    {
        i = lvalueInit!Impl;
    }
}
//-----

That's it for the "library".
We compile it as such:

dmd -lib foo/traits.d foo/file.d -ofmylib

From there, create a simple main.d:
//----- //main.d module main; import foo.file; void main() { auto f = F(5); } //----- Then build... dmd mylib.a -run main.d Undefined symbols for architecture x86_64: "_D3foo6traits32__T10lvalueInitTS3foo4file4ImplZ10lvalueInityS3foo4file4Impl", referenced from: _D3foo4file1F6__ctorMFNciZS3foo4file1F in mylib.a(file_3_46.o) ld: symbol(s) not found for architecture x86_64 --
May 16 2014