www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20423] New: Interface file and mangling do not agree about

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

          Issue ID: 20423
           Summary: Interface file and mangling do not agree about nothrow
                    dtors
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: rightfold+bugzilla+dlang gmail.com

When a struct dtor is marked nothrow then the interface file generated with -H
disagrees with the mangled name in the object file created with -c:

```
$ cat foo.d
module foo;

struct S
{
        nothrow ~this() {}
}
$ dmd -H -c foo.d
$ cat foo.di
// D import file generated from 'foo.d'
module foo;
struct S
{
        ~this();
}
$ nm foo.o | grep __dtor                                                        
0000000000000000 T _D3foo1S6__dtorMFNbZv
```

This causes linker errors:

```
$ cat bar.d
module bar;

import foo;

void main()
{
        auto s = S();
}
$ dmd bar.d foo.di foo.o
bar.o:bar.d:function _Dmain: error: undefined reference to
'_D3foo1S6__dtorMFZv'
```

Difference between symbols:
```
.o:  _D3foo1S6__dtorMFNbZv
.di: _D3foo1S6__dtorMFZv
```

Verified with:

 - DMD64 D Compiler v2.085.1
 - LDC 1.16.0 based on DMD v2.086.1 and LLVM 8.0.1

--
Dec 01 2019