www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18049] New: dmd -unittest against a library not compiled with

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

          Issue ID: 18049
           Summary: dmd -unittest against a library not compiled with
                    -unittest gives undefined symbols
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

This is a serious blocker, which could potentially lead to not being able to
compile with -unittest some code that depends on another library that was not
compiled with -unittest (eg could be phobos if phobos code uses pattern shown
in this bug)

dmd -lib -unittest -oflibfun.a fun.d
dmd -main -unittest main.d libfun.a
#works

dmd -lib -oflibfun.a fun.d
dmd -main -unittest main.d libfun.a
Undefined symbols for architecture x86_64:
  "_D3fun__T1ATtZQf8opEqualsMxFNaNbNiNfSQBj__TQBiTtZQBoZb", referenced from:
      _D3fun__T1ATtZQf11__xopEqualsFKxSQBf__TQBeTtZQBkKxQsZb in main.o
ld: symbol(s) not found for architecture x86_64


------------------
fun.d:
module fun;
struct A(T){
    bool opEquals(A!T) const {
        auto a=typeid(A!T);
        return true;
    }

    unittest {
        alias b = A!(ushort);
    }
}
enum ignore = A!int();

main.d:
module main;
import fun;


NOTE: this was obtained after painful manual reduction from
https://issues.dlang.org/show_bug.cgi?id=16477

--
Dec 08 2017