[Issue 18820] New: dip1000 mangling is different for inferred templates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 3 07:50:22 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18820

          Issue ID: 18820
           Summary: dip1000 mangling is different for inferred templates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: link-failure, safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com
                CC: bugzilla at digitalmars.com

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-350425051
https://github.com/dlang/dmd/pull/8124#issuecomment-379299121
https://github.com/dlang/phobos/pull/6443

--


More information about the Digitalmars-d-bugs mailing list