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

          Issue ID: 24477
           Summary: Union access of bool shouldn't be allowed in @safe
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: dkor...@live.nl

See https://issues.dlang.org/show_bug.cgi?id=20148#c8

```
bool schrodingersCat() @safe {
        union Box { bool b; ubyte y; }
        Box u;
        u.y = 2;
        return u.b;
}

void main() @safe {
        import std.stdio;
        bool b = schrodingersCat();
        if (b) writeln("alive");
        if (!b) writeln("dead");
}
```

--

Reply via email to