Second draft: Sum Type by Struct

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Thu Sep 10 17:56:21 UTC 2026


No.

```d
struct S {
align(1):
     ubyte a;
     ushort b;
}

void main() {
     S* s = new S;
     ushort* ptr = &s.b;
     writeln(cast(size_t)ptr & 1);

     GCWordVariant!(ubyte*, ushort*) v;

     writeln("ubyte*");
     v = typeof(v)(&s.a);

     writeln("ushort*");
     v = typeof(v)(ptr);

     writeln(v);
}
```

```
1
ubyte*
ushort*
core.exception.AssertError at onlineapp.d(86): Some tag bits are non-zero
----------------
??:? _d_assert_msg [0x609cd4acb7e8]
./onlineapp.d:86 _Dmain [0x609cd4aa767e]
```


More information about the dip.development mailing list