DIP74: Reference Counted Class Objects

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 27 08:35:34 PST 2015


On Fri, Feb 27, 2015 at 08:00:20AM -0800, Andrei Alexandrescu via Digitalmars-d wrote:
> On 2/27/15 7:42 AM, H. S. Teoh via Digitalmars-d wrote:
> >S.foo() should have been annotated with 'return', but the programmer
> >forgot and the compiler still accepts the code without any warnings,
> >thereby violating @safe.
> 
> That is correct. However, the user is on the hook because her use of
> @trusted when deallocating the array.
[...]

Which shows just how dangerous @trusted is. :-P  But that's a good
point. The use of @trusted in theory should have raised red flags that
the programmer needs to be careful here.  There's also the case of using
malloc/free to allocate the array, but I suppose that falls in the same
category.


T

-- 
A bend in the road is not the end of the road unless you fail to make the turn. -- Brian White


More information about the Digitalmars-d mailing list