www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21723] New: Linker error: two module static library, main

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

          Issue ID: 21723
           Summary: Linker error: two module static library, main compiled
                    inline, invariant that defines a function, type alias,
                    and an alias lambda
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Sorry for the random list of keywords in the summary but this one is pretty
opaque.

Take two modules:

a.d:
import b;
alias Struct = b.Struct;

b.d:
struct Struct {
    invariant { void call() { } }
    void templfun()() { }
}

main.d:
import a;

void trigger(Instance val) { val.templfun; }

void main() { alias lambda = a => a; }

Build as such:

dmd a.d b.d -lib -oflibrary.a
dmd -inline main.d ./library.a

Behold the linker error.

/usr/bin/ld: main.o: in function `pure nothrow  nogc  safe void
b.Struct.templfun!().templfun()':
main.d:(.text.pure nothrow  nogc  safe void
b.Struct.templfun!().templfun()[pure nothrow  nogc  safe void
b.Struct.templfun!().templfun()]+0xd): undefined reference to `const void
b.Struct.__invariant3()'
/usr/bin/ld: main.d:(.text.pure nothrow  nogc  safe void
b.Struct.templfun!().templfun()[pure nothrow  nogc  safe void
b.Struct.templfun!().templfun()]+0x19): undefined reference to `const void
b.Struct.__invariant3()'
collect2: error: ld returned 1 exit status



--
Mar 16 2021