www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18820] New: dip1000 mangling is different for inferred


          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 puremagic.com
          Reporter: schveiguy yahoo.com
                CC: bugzilla 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.


----- 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:

May 03 2018