[Issue 6167] New: RefCounted and lazy/delegate
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 16 16:02:13 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6167
Summary: RefCounted and lazy/delegate
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: jsancio at gmail.com
--- Comment #0 from Jose Garcia <jsancio at gmail.com> 2011-06-16 15:57:31 PDT ---
I am not sure what is going but this maybe a dmd bug so filing here. The
following program:
import std.typecons;
import std.exception;
struct Struct
{
this(int dummy) { refCount = RefCounted!Impl(Impl(dummy)); }
~this() {}
RefCounted!Impl refCount;
struct Impl { int dummy; }
Struct fun(bool now)
{
if(now) throw new Exception("");
return Struct(1);
}
}
void lazyFun(lazy Struct exp)
{
try { exp(); } catch(Exception e) {}
}
void delegateFun(Struct delegate() exp)
{
try { exp(); } catch(Exception e) {}
}
void main()
{
auto var = Struct(1);
try { auto result = var.fun(true); } catch(Exception e) {}
delegateFun({ return var.fun(true); }); // segfaults
lazyFun(var.fun(true)); // segfaults
assertThrown(var.fun(true)); // segfaults
}
Produces the following nonsensical output:
_RefCounted at 95F9410: initialized with (Impl _param_0)
RefCounted!(Impl)@B74B8E40: decrement refcount to 157258767
RefCounted!(Impl)@B74B8E40: decrement refcount to 157258766
RefCounted!(Impl)@95F940E: decrement refcount to 65535
Notice the value of the refcount!
--
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