www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19945] New: In betterC strange linker error can occur when

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

          Issue ID: 19945
           Summary: In betterC strange linker error can occur when
                    importing alias of template struct
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

I reproduced this problem with DMD v2.086.0 and DMD v2.085.1 and LDC 1.15.0. I
did not test other versions of DMD or LDC.


---
extern(C) void main()
{
    import std.random : LinearCongruentialEngine;
    enum A = 48_271, B = 0, C = 2_147_483_647;
    alias MyMinstdRand = LinearCongruentialEngine!(uint, A, B, C);
    MyMinstdRand gen;
    auto n = gen.front;
}
---


---
extern(C) void main()
{
    import std.random : LinearCongruentialEngine, MinstdRand;
    enum A = 48_271, B = 0, C = 2_147_483_647;
    alias MyMinstdRand = LinearCongruentialEngine!(uint, A, B, C);
    static assert(is(MyMinstdRand == MinstdRand), "definitions are identical");
}
---


---
extern(C) void main()
{
    import std.random : LinearCongruentialEngine, MinstdRand;
    enum A = 48_271, B = 0, C = 2_147_483_647;
    alias MyMinstdRand = LinearCongruentialEngine!(uint, A, B, C);
    static assert(is(MyMinstdRand == MinstdRand), "definitions are identical");
    MyMinstdRand gen; // error: undefined reference to
'_D3std6random__T24LinearCongruentialEngineTkVki48271Vki0Vki2147483647ZQCc6__initZ'
    auto n = gen.front; //error: undefined reference to
'_D3std6random__T24LinearCongruentialEngineTkVki48271Vki0Vki2147483647ZQCc5frontMxFNaNbNdNiNfZk'
}
---


directly.
---
extern(C) void main()
{
    import std.random : MinstdRand;
    MinstdRand gen; // error: undefined reference to
'_D3std6random__T24LinearCongruentialEngineTkVki48271Vki0Vki2147483647ZQCc6__initZ'
    auto n = gen.front; // error: undefined reference to
'_D3std6random__T24LinearCongruentialEngineTkVki48271Vki0Vki2147483647ZQCc5frontMxFNaNbNdNiNfZk'
}
---

--
Jun 06 2019