www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23723] New: Attributes incorrectly inferred given the same

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

          Issue ID: 23723
           Summary: Attributes incorrectly inferred given the same source
                    but compiled individually
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: 212fahrenheit posteo.us

This will compile with dmd-2.101.2, but will produce a linking error when using
dmd-2.102.0 or dmd-2.102.1

After upgrading DMD my project it will not build, reducing this was a head
scratcher. this is my first time reporting on the tracker here, so hopefully I
did a good job, if not, please tell what to do better next time.

I'm not sure what is going on, but I think this has something to do with
attributes being inferred incorrectly, but I may be off the mark, what's also
odd is that if you pass both files at once this bug will not be reproduced.

using `nm` I can see two different signatures

void std.typecons.SafeRefCounted!(test2.MyStruct, 1).SafeRefCounted.__dtor()
pure nothrow  nogc void std.typecons.SafeRefCounted!(test2.MyStruct,
1).SafeRefCounted.__dtor()


How to reproduce bug:

build using: dmd -c test.d && dmd -c test2.d && dmd test.o test2.o

test.d
```
void main(){
        import test2;
        MyStruct.RcPtr gl_indcies = MyStruct.RcPtr(MyStruct());
}
```

test2.d
```
module test2;
struct MyStruct{
        import std.typecons : SafeRefCounted, Unique;
        alias Ptr = Unique!(MyStruct);
        alias RcPtr = SafeRefCounted!(MyStruct);
        ~this(){}
}
```

this is the linking error produced
```
/bin/ld: test.o: in function `_Dmain':
test.d:(.text._Dmain[_Dmain]+0x2f): undefined reference to
`_D3std8typecons__T14SafeRefCountedTS5test28MyStructVEQBzQBy24RefCountedAutoInitializei1ZQCs6__dtorMFZv'
collect2: error: ld returned 1 exit status
```a

--
Feb 16 2023