Read-only property without @property

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 26 17:58:22 PDT 2014


On Fri, Sep 26, 2014 at 07:32:49PM -0400, Steven Schveighoffer via Digitalmars-d wrote:
> On 9/26/14 6:32 PM, H. S. Teoh via Digitalmars-d wrote:
> 
> >Does the compiler infer it as @safe, though?
> 
> Hm... good point, I'm not sure if unions are considered @safe. But I
> think that would be a decent enhancement request if not.
[...]

	union U {
		int* ptr;
		long i;
	}

	void main() @safe {
		U u;
		u.i = 12345;
		*u.ptr = 54321; // this can't possibly be @safe
	}

How would the compiler decide which union operations are @safe and which
are not?


T

-- 
He who laughs last thinks slowest.


More information about the Digitalmars-d mailing list