Bug 17339 – ambiguous mangling with const alias argument

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-04-22T00:11:00Z
Last change time
2017-08-07T13:15:54Z
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2017-04-22T00:11:12Z
cat > bug.d << CODE void bug(alias param)() { pragma(msg, __traits(identifier, param)); } // works for enums enum ENUM1 = 1; enum ENUM2 = 1; static assert(&bug!ENUM1 is &bug!ENUM2); // OK, same instances static assert(bug!ENUM1.mangleof == bug!ENUM2.mangleof); // OK, same mangling // works for values auto VAL1 = 1; auto VAL2 = 1; static assert(&bug!VAL1 !is &bug!VAL2); // OK, different instances static assert(bug!VAL1.mangleof != bug!VAL2.mangleof); // OK, different mangling // fails for const values const CONST1 = 1; const CONST2 = 1; static assert(&bug!CONST1 !is &bug!CONST2); // different instances static assert(bug!CONST1.mangleof != bug!CONST2.mangleof); // but same mangling (like enum values) CODE dmd -c bug ---- ENUM1 VAL1 VAL2 CONST1 CONST2 bug.d(20): Error: static assert ("_D3bug13__T3bugVxii1Z3bugFNaNbNiNfZv" != "_D3bug13__T3bugVxii1Z3bugFNaNbNiNfZv") is false ---- Const module level template alias arguments are mangled as their constant value, just like enums, but the instances are not identical and are actually emitted multiple times. 0000000000000000 W pure nothrow @nogc @safe void bug.bug!(1).bug() 0000000000000008 W pure nothrow @nogc @safe void bug.bug!(1).bug() Should be fixed one way or the other, either treating them like enums, or like non-const values.
Comment #1 by github-bugzilla — 2017-04-22T05:24:53Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b21f445de6e4e8aeb5447c09fde0e8fb179ce99c workaround Issue 17339 - ambiguous mangling with const alias args - with multiple definitions with identical mangling getsegment(".text", p) returns the section from the previous instance and later the linker complains about a group referencing an earlier section - fixed by reusing the existing group section (while leaving the new one empty)
Comment #2 by uplink.coder — 2017-04-22T09:31:26Z
Instances should be merged!
Comment #3 by github-bugzilla — 2017-04-24T01:13:58Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/da7e3bcabb4e9441391ecb5f2c9d3ea0b11cee7c fix Issue 17339 - ambiguous mangling with const alias argument - don't constfold const/immutable variables to generate the mangling for alias template arguments https://github.com/dlang/dmd/commit/30e701eb64ac1505f9fcca69177aaa42efe22428 remove Issue 17339 workaround https://github.com/dlang/dmd/commit/eb3bc8d8902a0b0c3b3b02058265d811ec310eb9 Merge pull request #6719 from MartinNowak/fix17339 fix Issue 17339 - ambiguous mangling with const alias argument
Comment #4 by github-bugzilla — 2017-06-17T11:34:05Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b21f445de6e4e8aeb5447c09fde0e8fb179ce99c workaround Issue 17339 - ambiguous mangling with const alias args https://github.com/dlang/dmd/commit/da7e3bcabb4e9441391ecb5f2c9d3ea0b11cee7c fix Issue 17339 - ambiguous mangling with const alias argument https://github.com/dlang/dmd/commit/30e701eb64ac1505f9fcca69177aaa42efe22428 remove Issue 17339 workaround https://github.com/dlang/dmd/commit/eb3bc8d8902a0b0c3b3b02058265d811ec310eb9 Merge pull request #6719 from MartinNowak/fix17339
Comment #5 by github-bugzilla — 2017-07-01T21:07:43Z
Commit pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/934a423ec91fa2e74961153d6cb6fd53435d510b Revert "remove Issue 17339 workaround" This reverts commit 30e701eb64ac1505f9fcca69177aaa42efe22428.
Comment #6 by github-bugzilla — 2017-07-05T19:09:53Z
Comment #7 by github-bugzilla — 2017-08-07T13:15:54Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/b21f445de6e4e8aeb5447c09fde0e8fb179ce99c workaround Issue 17339 - ambiguous mangling with const alias args https://github.com/dlang/dmd/commit/da7e3bcabb4e9441391ecb5f2c9d3ea0b11cee7c fix Issue 17339 - ambiguous mangling with const alias argument https://github.com/dlang/dmd/commit/30e701eb64ac1505f9fcca69177aaa42efe22428 remove Issue 17339 workaround https://github.com/dlang/dmd/commit/eb3bc8d8902a0b0c3b3b02058265d811ec310eb9 Merge pull request #6719 from MartinNowak/fix17339 https://github.com/dlang/dmd/commit/934a423ec91fa2e74961153d6cb6fd53435d510b Revert "remove Issue 17339 workaround"