www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13043] New: Redundant linking to TypeInfo in non-root module

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

          Issue ID: 13043
           Summary: Redundant linking to TypeInfo in non-root module
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: link-failure
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

In below test case, 'y' is non-root module, and typeid(Inner) is completely
unneeded for the 'test' module compilation. But with -g -inline -version=bug,
it is unnecessarily referenced and fail to link.

module test;
import y;
void main() {}

module y;
struct QualifiedNameTests
{
    struct Inner
    {
        const int opCmp(ref const Inner) { return 0; }
    }

    shared(const(Inner[string])[]) data;

  version(bug)
    size_t toHash() const
    {
        return typeid(typeof(data)).getHash(cast(const void*)&data);
    }
}


Command line:
dmd -version=bug -g -inline test.d

Output:
 Error 42: Symbol Undefined
_D1y18QualifiedNameTests5Inner5opCmpMxFKxS1y18QualifiedNameTests5InnerZi

--
Jul 04 2014