[Issue 21512] New: RedBlackTree!Tid treat any values as duplicated except for Tid.init
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 29 07:52:34 UTC 2020
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 at puremagic.com
Reporter: ttanjo at 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 at onlineapp.d(17): 3 is expected but 2
----------------
??:? _d_assert_msg [0x561d2f2e6fee]
onlineapp.d:17 _Dmain [0x561d2f2d2ab5]
```
--
More information about the Digitalmars-d-bugs
mailing list