There is a fix for it in todays trunk. Will report back the results. The original code should now compile.
[edit]
The original code now compiles, and runs correctly first time, but there is still a problem because the CS is not released correctly, so running a second time gives:
Error: Invalid argument index in format "A RTTI object with handle 0x%x is already registered"
Thread done.1That is easy to overlook if you do not run the code a second time. Running it first time now succeeds.
The OS resource, the CS, is not (yet) correctly released. This can't be caught with heaptrc.
As I referred to before the issue is that on both Linux and Windows the synchronization primitives are kernel objects, so if they are not released, running a second time will fail.