Bug 7469 – template mangling depends on instantiation order
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-08T20:26:00Z
Last change time
2015-09-03T05:29:45Z
Keywords
pull, wrong-code
Assigned to
code
Creator
code
Comments
Comment #0 by code — 2012-02-08T20:26:03Z
---- 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 by code — 2012-02-09T04:36:14Z
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.
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 by k.hara.pg — 2014-01-28T22:53:10Z
*** Issue 12020 has been marked as a duplicate of this issue. ***
Comment #5 by k.hara.pg — 2014-05-09T18:31:34Z
*** Issue 12720 has been marked as a duplicate of this issue. ***