www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21512] New: RedBlackTree!Tid treat any values as duplicated

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

          Issue ID: 21512
           Summary: RedBlackTree!Tid treat any values as duplicated except
                    for Tid.init
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ttanjo gmail.com

The following code should work but it doesn't with dmd 2.094.2 on Linux
systems.

https://run.dlang.io/is/kd2GFP

```
import std;

void main(string[] args)
{
    alias lessTid = (in Tid a, in Tid b) => a.to!string < b.to!string;
    auto c = make!(RedBlackTree!(Tid, lessTid));

    c.insert(Tid.init);
    assert(c.length == 1);

    auto tid1 = spawn(() {});
    c.insert(tid1);
    assert(c.length == 2);

    auto tid2 = spawn(() {});
    c.insert(tid2);
    assert(c.length == 3, format!"3 is expected but %s"(c.length)); // Line 17
}
```

Expected behavior: It runs without errors.
Actual behavior: It fails with the following message:
```
core.exception.AssertError onlineapp.d(17): 3 is expected but 2
----------------
??:? _d_assert_msg [0x561d2f2e6fee]
onlineapp.d:17 _Dmain [0x561d2f2d2ab5]
```

--
Dec 28 2020