Issue 7469 - template mangling depends on instantiation order
Summary: template mangling depends on instantiation order
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 major
Assignee: Martin Nowak
URL:
Keywords: pull, wrong-code
: 10914 12020 12696 12720 (view as issue list)
Depends on:
Blocks:
 
Reported: 2012-02-08 20:26 UTC by Martin Nowak
Modified: 2015-09-03 05:29 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2012-02-08 20:26:03 UTC
---- bug.d ----
struct Foo(int i)
{
}

version (A)
{
    Foo!3  fooa;
    Foo!3u foob;
}
else
{
    Foo!3u fooa;
    Foo!3  foob;
}

pragma(msg, typeof(fooa).mangleof);
pragma(msg, typeof(foob).mangleof);
----
dmd -c bug.d

S3bug11__T3FooVk3Z3Foo
S3bug11__T3FooVk3Z3Foo
----
dmd -c -version=A bug.d

S3bug11__T3FooVi3Z3Foo
S3bug11__T3FooVi3Z3Foo

----

The mangling should depend on the template value parameter type
not the type of the argument.
Comment 1 Martin Nowak 2012-02-09 04:36:14 UTC
cat > bug.d << EOF
struct S128(T, int k=1)
{
}

version (A)
{
    alias S128!(int) fooa;
    alias S128!(int, 1) foob;
}
else
{
    alias S128!(int, 1) fooa;
    alias S128!(int) foob;
}

pragma(msg, fooa.mangleof);
pragma(msg, foob.mangleof);
EOF

dmd -c bug.d
dmd -c -version=A bug.d
----
S3bug14__T4S128TiVi1Z4S128
S3bug14__T4S128TiVi1Z4S128
----
S3bug11__T4S128TiZ4S128
S3bug11__T4S128TiZ4S128
----
Similar bug with default values.
Comment 3 Martin Nowak 2013-10-13 16:34:55 UTC
Fixing this issue would allow us to use the mangling as hash key for looking up existing template instantiations. Currently the template arguments are used for comparison and to compute the hash (TemplateDeclaration::findExistingInstance).
Comment 4 Kenji Hara 2014-01-28 22:53:10 UTC
*** Issue 12020 has been marked as a duplicate of this issue. ***
Comment 5 Kenji Hara 2014-05-09 18:31:34 UTC
*** Issue 12720 has been marked as a duplicate of this issue. ***
Comment 6 Kenji Hara 2014-05-09 19:11:02 UTC
https://github.com/D-Programming-Language/dmd/pull/3536

I think this is important to stabilize symbol mangling. Change to 'major' bug.
Comment 8 github-bugzilla 2014-05-09 22:40:56 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/cc5029603a0ce7051b7e24642705c1d8ec6c5e02
fix Issue 7469 - template mangling depends on instantiation order

https://github.com/D-Programming-Language/dmd/commit/5c5bd27f748e5b2b095915bfd187ab7561d6d142
Merge pull request #3536 from 9rnsr/fix7469

Issue 7469 - template mangling depends on instantiation order
Comment 9 github-bugzilla 2014-05-24 09:14:38 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c9120823c6740dc8141ac153f4da56600b147d73
[Refactoring] Remove comment-out code for the fixed issue 7469
Comment 10 Kenji Hara 2015-01-06 08:40:26 UTC
*** Issue 10914 has been marked as a duplicate of this issue. ***
Comment 11 Kenji Hara 2015-09-03 05:29:45 UTC
*** Issue 12696 has been marked as a duplicate of this issue. ***