[Issue 22041] SumType assignments should work with pointers in @safe code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 19 00:43:00 UTC 2021


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

Paul Backus <snarwin+bugzilla at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |snarwin+bugzilla at gmail.com
         Resolution|---                         |INVALID

--- Comment #2 from Paul Backus <snarwin+bugzilla at gmail.com> ---
This would allow undefined behavior in @safe code:

---
int n;

int example() @safe
{
    SumType!(int*, int) x = &n;
    return x.match!(
        (int n) => n,
        (ref int* p) {
            x = 123456789; // overwrites p (currently @system)
            return *p; // kaboom
        }
    );
}
---

--


More information about the Digitalmars-d-bugs mailing list