Thread overview
[Issue 3031] scoped static var conflicts
[Issue 3031] scoped static var conflicts while linking
Jul 26, 2015
Mathias LANG
Jul 26, 2015
Mathias LANG
Jul 27, 2015
Kenji Hara
Jul 27, 2015
Kenji Hara
Jul 27, 2015
Kenji Hara
May 24, 2020
Basile-z
Jun 07, 2020
Dlang Bot
June 09, 2015
https://issues.dlang.org/show_bug.cgi?id=3031

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 & D2                     |D2

--
July 26, 2015
https://issues.dlang.org/show_bug.cgi?id=3031

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com
         Depends on|                            |14381

--- Comment #9 from Mathias LANG <pro.mathias.lang@gmail.com> ---
Nowadays it gives the following error:

test.d(14): Error: declaration test.func.j is already defined in another scope
in func

Since https://issues.dlang.org/show_bug.cgi?id=11720 was 'fixed'.
I'll make it depend on https://issues.dlang.org/show_bug.cgi?id=14831, because
the issue doesn't explicitly say which fix was expected.

There's also a 20$ bounty on this, so if you guys feel the error message fixes it, feel free to send Kenji (https://github.com/D-Programming-Language/dmd/pull/2947) his reward ;)

--
July 26, 2015
https://issues.dlang.org/show_bug.cgi?id=3031

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|14381                       |14831

--
July 27, 2015
https://issues.dlang.org/show_bug.cgi?id=3031

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|14831                       |

--
July 27, 2015
https://issues.dlang.org/show_bug.cgi?id=3031

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|link-failure                |
            Summary|scoped static var conflicts |scoped static var conflicts
                   |while linking               |

--- Comment #10 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to Mathias LANG from comment #9)
> Nowadays it gives the following error:
> 
> test.d(14): Error: declaration test.func.j is already defined in another
> scope in func
> 
> Since https://issues.dlang.org/show_bug.cgi?id=11720 was 'fixed'.

So now, the test case won't cause link-failure. Updated summary and keywords.

If the static variables are in extern(D) function, they can have unique mangled
names.

But, if they're not in extern(D) function, or does not have extenr(D) linkage,
they might conflict. For example:

extern(C++) foo()
{
    { extern(C++) static int var; pragma(msg, var.mangleof); }
    { extern(C++) static int var; pragma(msg, var.mangleof); }  // disallowed?
}

--
July 27, 2015
https://issues.dlang.org/show_bug.cgi?id=3031

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timothee.cour2@gmail.com

--- Comment #11 from Kenji Hara <k.hara.pg@gmail.com> ---
*** Issue 11720 has been marked as a duplicate of this issue. ***

--
June 29, 2017
https://issues.dlang.org/show_bug.cgi?id=3031

feklushkin.denis@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |feklushkin.denis@gmail.com

--
May 24, 2020
https://issues.dlang.org/show_bug.cgi?id=3031

Basile-z <b2.temp@gmx.com> changed:

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

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

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

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

--- Comment #12 from Dlang Bot <dlang-bot@dlang.rocks> ---
@NilsLankila created dlang/dmd pull request #11250 "fix issue 3031 - static var and func declaration conflict in different sub scope" fixing this issue:

- fix issue 3031 - static var and func declaration conflict in different sub scope

  The approach of the fix is based on the observation that the fundamental (and
only) problem was that allowing such declarations would produce same mangling.
  Now when the insertion in the scope fails, and if the declaration was static,
its name is changed and a **local** alias declaration, taking the previous
name, is generated.

  This works because:
  - the static declaration, the one that needs a unique mangle, has now an
unique identifier.
  - the code following the declaration use the new alias.

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

--
April 17, 2021
https://issues.dlang.org/show_bug.cgi?id=3031

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg
         Resolution|---                         |FIXED

--- Comment #13 from moonlightsentinel@disroot.org ---
Fixed in 2.095.1

--