Thread overview
[Issue 20565] Local template function in static foreach yields link error LNK1179 on fresh compile
[Issue 20565] Local template declarations in different scopes produce uncaught name collisions
Jan 04
Dlang Bot
Jan 10
Dlang Bot
Jan 12
Dlang Bot
February 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20565

simon.vanbernem@yahoo.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |link-failure

--- Comment #1 from simon.vanbernem@yahoo.de ---
This only seems to repro with the -m64 compiler switch activated.

--
February 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20565

simon.vanbernem@yahoo.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal

--
January 02
https://issues.dlang.org/show_bug.cgi?id=20565

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
MS-COFF is alone in not allowing two identical COMDATs from residing in the same object file, which is what is happening here. The two identical COMDATs are still generated for other targets, and the linker helpfully just merges them.

Can't fix the Microsoft linker, so I'll have to find out just why the two COMDATs are being generated and fix it.

--
January 03
https://issues.dlang.org/show_bug.cgi?id=20565

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
                 OS|Windows                     |All

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
A simpler demonstration of the problem:

  void main()
  {
    {
        int temp(T)() { return 3; }

        temp!int();
    }

    {
        int temp(T)() { return 4; }

        temp!int();
    }
  }

which affects all targets. Both functions are generated, the mangled names of the two functions are the same, and on non-MSCOFF targets one of the two functions is picked. Changing this to All platforms.

--
January 03
https://issues.dlang.org/show_bug.cgi?id=20565

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
Rewriting the bug example with functions instead of templates, an error is correctly generated:

  void main()
  {
    {
        int temp() { return 3; }

        temp();
    }

    {
        int temp() { return 4; }

        temp(); // Error: declaration test.main.temp is already defined in
another scope in main at line 6
    }
  }

This suggests the obvious fix of extending the check for functions to include template functions.

--
January 04
https://issues.dlang.org/show_bug.cgi?id=20565

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Local template function in  |Local template declarations
                   |static foreach yields link  |in different scopes produce
                   |error LNK1179 on fresh      |uncaught name collisions
                   |compile                     |

--
January 04
https://issues.dlang.org/show_bug.cgi?id=20565

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #12095 "fix Issue 20565 - Local template declarations in different scopes pro…" fixing this issue:

- fix Issue 20565 - Local template declarations in different scopes produce uncaught name collisions

https://github.com/dlang/dmd/pull/12095

--
January 04
https://issues.dlang.org/show_bug.cgi?id=20565

Walter Bright <bugzilla@digitalmars.com> changed:

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

--
January 10
https://issues.dlang.org/show_bug.cgi?id=20565

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #12119 "Issue 20565 - Local template declarations in different scopes produce…" mentioning this issue:

- Issue 20565 - Local template declarations in different scopes produce uncaught name collisions

https://github.com/dlang/dmd/pull/12119

--
January 12
https://issues.dlang.org/show_bug.cgi?id=20565

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12119 "fix Issue 20565 - Local template declarations in different scopes produce…" was merged into master:

- 96049dc779989d3d27c5fbaf58cc30681a305fa7 by Walter Bright:
  fix Issue 20565 - Local template declarations in different scopes produce
uncaught name collisions

https://github.com/dlang/dmd/pull/12119

--