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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 29 07:04:30 PDT 2013


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



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-08-29 07:04:28 PDT ---
(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.

-- 
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