Jump to page: 1 2
Thread overview
[Issue 15324] symbol is already defined / size of symbol changed
[Issue 15324] symbol is already defined
Nov 13, 2015
Johannes Pfau
Nov 13, 2015
Johannes Pfau
Nov 13, 2015
Johannes Pfau
Nov 13, 2015
Johannes Pfau
Nov 16, 2015
Iain Buclaw
Jan 06, 2016
Vincent R
Mar 20, 2016
Iain Buclaw
May 29, 2016
Ellery Newcomer
May 31, 2016
Johannes Pfau
Oct 24, 2017
Walter Bright
Dec 17, 2022
Iain Buclaw
Jun 28, 2023
RazvanN
November 13, 2015
https://issues.dlang.org/show_bug.cgi?id=15324

Johannes Pfau <johannespfau@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johannespfau@gmail.com

--- Comment #1 from Johannes Pfau <johannespfau@gmail.com> ---
Created attachment 1567
  --> https://issues.dlang.org/attachment.cgi?id=1567&action=edit
reduced test case

I've added a dustmite reduced test case. Compile like this:

dmd main.d
/usr/bin/ld: Warning: size of symbol
`_D4main179__T19MultiIndexContainerTC4core6thread6ThreadTS4main113__T9IndexedByS964main89__T6HashedVbi0VAyaa1_61VAyaa21_7479706569642861292e6765744861736828266129VAyaa4_613d3d62ZZ9IndexedByZ19MultiIndexContainer9__mixin108containsMxFC4core6thread6ThreadZb'
changed from 111 in main.o to 103 in main.o

gdc main.d
/tmp/cczTwcpO.s: Assembler messages:
/tmp/cczTwcpO.s:195: Error: symbol
`_D4main179__T19MultiIndexContainerTC4core6thread6ThreadTS4main113__T9IndexedByS964main89__T6HashedVbi0VAyaa1_61VAyaa21_7479706569642861292e6765744861736828266129VAyaa4_613d3d62ZZ9IndexedByZ19MultiIndexContainer9__mixin108containsMxFC4core6thread6ThreadZb'
is already defined



It seems scary that the size of the symbol changes. But maybe the bigger issue is that the template is actually emitted twice to the same object file. This seems to be tolerated by ld (dmd only gets a warning) but not by the assembler (gdc outputs asm and calls the assembler which refuses to assemble this).

Pinging Iain as I'm not sure if the assembler only complains because the size differs or whether it will still complain even if the size difference is fixed.

--
November 13, 2015
https://issues.dlang.org/show_bug.cgi?id=15324

Johannes Pfau <johannespfau@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical

--
November 13, 2015
https://issues.dlang.org/show_bug.cgi?id=15324

--- Comment #2 from Johannes Pfau <johannespfau@gmail.com> ---
Raised importance to critical as this prevents some of the bigger D projects from sucessfully compiling with GDC (pyd, wxD).

--
November 13, 2015
https://issues.dlang.org/show_bug.cgi?id=15324

Johannes Pfau <johannespfau@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|symbol is already defined   |symbol is already defined /
                   |                            |size of symbol changed

--
November 16, 2015
https://issues.dlang.org/show_bug.cgi?id=15324

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #3 from Iain Buclaw <ibuclaw@gdcproject.org> ---
(In reply to Johannes Pfau from comment #1)
> Pinging Iain as I'm not sure if the assembler only complains because the size differs or whether it will still complain even if the size difference is fixed.

My understanding is that GAS will complain and error for *any* duplicate symbol, regardless of what flags are associated with it, or size it has.

--
January 06, 2016
https://issues.dlang.org/show_bug.cgi?id=15324

Vincent R <v.richomme@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |v.richomme@gmail.com

--- Comment #4 from Vincent R <v.richomme@gmail.com> ---
Any progress ??

--
March 20, 2016
https://issues.dlang.org/show_bug.cgi?id=15324

--- Comment #5 from Iain Buclaw <ibuclaw@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().

--
May 29, 2016
https://issues.dlang.org/show_bug.cgi?id=15324

--- Comment #6 from Ellery Newcomer <ellery-newcomer@utulsa.edu> ---
this prevents pyd from compiling under gdc:

https://github.com/ariovistus/pyd/issues/42

--
May 31, 2016
https://issues.dlang.org/show_bug.cgi?id=15324

Johannes Pfau <johannespfau@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal

--- Comment #7 from Johannes Pfau <johannespfau@gmail.com> ---
Reducing importance: As explained by Iain, the reported example is invalid D code. DMD should still warn about this.

Additionally, there are cases where DMD passes template symbols multiple times to the backend. I don't have a test case right now, but we added a workaround for this to GDC and GDC will now compile such code. So this is no longer a blocker for GDC.

--
October 24, 2017
https://issues.dlang.org/show_bug.cgi?id=15324

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=17332

--
« First   ‹ Prev
1 2