ref is unsafe
Jonathan M Davis
jmdavisProg at gmx.com
Sun Dec 30 17:42:47 PST 2012
On Monday, December 31, 2012 02:37:56 Rob T wrote:
> This may be far fetched, but consider this,
>
> If a function returns a ref that is the same as what was passed
> in by ref, then the passed and return addresses would match,
> which means that it still may be possible for the compiler to
> detect the situation.
>
> This is more complicated in the case where a user defined struct
> was passed by ref, and the ref return type is a member from that
> struct, but it still may be possible to detect it.
>
> If address matching is possible (or is that determined only at
> link time?) then it may be possible to detect a situation that
> should be illegal and flagged as a compiler error.
Addresses would only be known at runtime, and it's far too late at that point.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list