August 14, 2023
https://issues.dlang.org/show_bug.cgi?id=24085

          Issue ID: 24085
           Summary: Separate Compilation Bugs
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: puneet@coverify.org

Created attachment 1885
  --> https://issues.dlang.org/attachment.cgi?id=1885&action=edit
Reduced code to replicate the issue

When source files are compiled separately, DMD is not creating symbols for certain templatized methods (opCast).

To replicate the issue, please untar the attachment and run compile.sh



// foo.d
module foo;
version (SIGNED) alias INT = int;
version (UNSIGNED) alias INT = uint;
template Foo(N...) {
  alias  Foo = FooImpl!(N);
}
struct FooImpl(INT N)   {
  void opAssign(V)(V) { }
  void opAssign(bool) { }
  ubyte getValue() {
    return cast(ubyte) this;
  }
  alias getValue this;
  V opCast(V)() { assert (false); }
}
auto toFoo(INT N, T)(T ) {
  return Foo!N();
}

// bar.d
import foo;
import frop;
struct Bar { Foo!0    bar; }


// frop.d
import foo;
import bar;
Foo!0 frop() { return toFoo!0(0); }

// dmd -version=UNSIGNED -c frop.d
// dmd -version=UNSIGNED -c bar.d

// nm bar.o frop.o | ddemangle | grep opCast

--