I recently played around with atomic operations. While doing so, I noticed a problem with the interaction of interfaces and cas. Consider the following program:

```
import core.atomic;
import std.stdio;

interface TestInterface
{
}

class TestClass : TestInterface
{
}

void main()
{
    shared TestInterface testInterface = new shared TestClass;
cas(&testInterface, testInterface, new shared TestClass).writeln;
    writeln(typeid(testInterface));
}
```
(https://run.dlang.io/is/9P7PAb)

This program compiles successfully and outputs

```
true
Error: program killed by signal 11
```

i.e. a segmentation fault happens.

When replacing "interface" with "abstract class" (https://run.dlang.io/is/sFaO1k), everything works as expected and the program outputs

```
true
onlineapp.TestClass
```

Is this actually a bug or a fundamental limitation of cas and interfaces? Did I do anything wrong?

Reply via email to