[Issue 19916] union member access should be un- at safe

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 3 10:43:33 UTC 2024


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

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #24 from Nick Treleaven <nick at geany.org> ---
(In reply to Simen Kjaeraas from comment #5)
> struct NotAPointer {
>     private size_t n;
>     @disable this();
>     @trusted this(int* p) {
>         assert(p.isValid);
>         n = cast(size_t)p;
>     }
>     @trusted void callMethod() {
>         *cast(int*)n = 3;
>     }
> }

The answer to this is to mark `n` as `@system`.

--


More information about the Digitalmars-d-bugs mailing list