Bug 18820 – dip1000 mangling is different for inferred templates
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-03T07:50:22Z
Last change time
2019-03-28T08:41:28Z
Keywords
link-failure, safe
Assigned to
No Owner
Creator
Steven Schveighoffer
Comments
Comment #0 by schveiguy — 2018-05-03T07:50:22Z
If a template/auto function has attributes inferred, and you compile a module with dip1000 and another module without, the mangling may depend on new attributes inferred by dip1000, which makes it impossible to link.
Example:
----- mod2.d:
module mod2;
auto foo(T)(T s) @safe
{
return s;
}
auto foo2(scope string s)
{
return foo(s);
}
----- mod1.d:
module mod1;
import mod2;
void main()
{
scope string s;
auto x = foo2(s);
}
If we compile like this:
dmd -c mod2.d
dmd -dip1000 mod1.d mod2.o
We have linker errors.
Compiling both together works:
dmd mod1.d mod2.d
dmd -dip1000 mod1.d mod2.d
The fundamental problem here is that it makes dip1000 NOT an optional switch, but a required switch. So if we plan to ship with dip1000, it will force everyone not only to use dip1000, but to make sure ALL their code (including code they may not control) to use dip1000.
I don't know a solution to this other than to ship 2 libraries.
Walter asked me to add this so there is a bugzilla report about it.
See discussions at: https://github.com/dlang/phobos/pull/5915#issuecomment-350425051https://github.com/dlang/dmd/pull/8124#issuecomment-379299121https://github.com/dlang/phobos/pull/6443