[Issue 10921] scoped returns a reference to an uninitialized object

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 29 18:38:55 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10921



--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2013-08-29 18:38:53 PDT ---
(In reply to comment #2)
> (In reply to comment #0)
> > -----
> >     Point p2 = scoped!Point(1, 2);
> >     assert(p2.x == 1, p2.x.text);  // fails, == 0
> >     assert(p2.y == 2, p2.y.text);  // fails, == 0
> > }
> > -----
> 
> I see now what's going on, the internal voldemort type `static struct Scoped`
> has a dtor, and it is called because this struct is thrown away when you just
> want to assign the reference to the object at the call site.
> 
> So the bug report itself is invalid, however this should really be documented
> because it's very hard to spot what went wrong.

We should disable the implicit conversion from Scoped to Point.
I think we can use Proxy mixin instead of alias this for the purpose.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list