www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20968] New: Linker error of uninstantiated templated

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

          Issue ID: 20968
           Summary: Linker error of uninstantiated templated `opEquals`
                    member of struct when compiled with -preview=in
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: per.nordlow gmail.com

A file named rational.d containing


Rational!(I1) rational(I1, I2)(I1 , I2)
{
    return typeof(return)();
}

struct Rational(Int)
{
    bool opEquals(Rhs)(Rhs _) {}
}

 nogc unittest
{
    auto _ = rational(1, 2);
}


compiled as

    dmd -main -unittest -preview=in rational.d

fails to link as

rational.o:__main.d:_D36TypeInfo_S8rational__T8RationalTiZQm6__initZ: error:
undefined reference to '_D6object10_xopEqualsFMxPvMxQeZb'

Compiling without -preview=in as

    dmd -main -unittest rational.d

makes the linking pass.

--
Jun 21