[Issue 6581] New: Yet another dtor/postblit problem?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Aug 30 14:12:45 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6581
Summary: Yet another dtor/postblit problem?
Product: D
Version: D2
Platform: Other
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dmitry.olsh at gmail.com
--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2011-08-30 14:12:40 PDT ---
Test case creates a instance of nested struct, and prints ctor/postblit/dtor
activity + address of this. Reduced from upcoming regex module, where it's
causing segfaults but only with -inline (dumb luck?).
import std.stdio;
struct R
{
this(int k)
{
writefln("R created %x", &this);
}
this(this){ writefln("R postblit %x", &this); }
~this(){ writefln("R destroyed %x", &this); }
}
struct S
{
R _match;
this( int separator)
{
_match = R(separator);
writefln("S created %x", cast(void*)&this);
}
this(this)
{
writefln("S postblit %x", cast(void*)&this);
}
~this()
{
writefln("S destroyed %x", cast(void*)&this);
}
}
void split(int rx)
{
auto spl = S(rx);
writefln("**** Spl is at address %x", cast(void*)&spl);
}
void main(string[] argv)
{
split(42);
}
The end result for me looks like this:
R created 18fdc0
R destroyed 18fdc4 // killed wrong guy or missing a postblit at 18fe08?
S created 18fe08
**** Spl is at address 18fe08
S destroyed 18fe08
R destroyed 18fe08
Bottom line: dtor called twice, ctor called once and not a single postblit.
Saldo is negative ...
That's on almost latest DMD (commit c5c8500a13f222935f00145c16dfbc2d32351b0f)
--
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