[Issue 15324] symbol is already defined / size of symbol changed

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Mar 20 14:47:57 PDT 2016


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

--- Comment #5 from Iain Buclaw <ibuclaw at gdcproject.org> ---
I don't think it's a compiler bug, but it would help indefinitely if only the
compiler semantic passes checked for conflicting function overrides upon
declaration, rather than when they are called.

I can distil test case down to:

---
struct MultiIndexContainer()
{
    bool contains(int k) const
    {
        auto r = true;
        return r;
    }

    bool contains(int k) const
    {
        return false;
    }
}

void main()
{  
    MultiIndexContainer!() m;
}

---

If these were not templates, you'd get multiple definition errors.  But as that
is not the case, these instead get put on comdat and merged. This as you've
discovered gives you an entirely different kind of linker error, but it's
simply a different side of the same coin.

The real bug is in the program logic.  Somehow, you have done the following
(abridged)
---
alias Value ValueView;
alias typeof(Value.init) KeyType;
bool contains(ValueView value) const { ... }
bool contains(KeyType k) const { ... }
---

You should add a constraint to ensure that ValueView != KeyType, or rename the
methods so as they don't conflict, such as containsValue() and containsKey().

--


More information about the Digitalmars-d-bugs mailing list