Bug 15661 – [REG2.067.0] Destructor called while object still alive
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-02-09T00:19:00Z
Last change time
2016-02-23T10:04:31Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
matt.elkins
Comments
Comment #0 by matt.elkins — 2016-02-09T00:19:12Z
In the code below the TileView destructor is called twice (see the output at the bottom). The first call of the destructor appears to occur while the TileView object is still alive. The expected output (also listed at the bottom) occurs if any of a number of changes are made to the code, including but probably not limited to:
* Creating the TextureHandles directly rather than calling create()
* Using only one argument to TileView's constructor
* Removing TextureHandle's empty destructor
This is on DMD 2.070 32-bit, running on 64-bit Windows 7.
[code]
import std.stdio;
struct TextureHandle
{
~this() {}
}
TextureHandle create() {return TextureHandle();}
struct TileView
{
@disable this();
@disable this(this);
this(TextureHandle a, TextureHandle b) {}
~this() {writeln("HERE2");}
}
struct View
{
this(int)
{
writeln("HERE1a");
m_tileView = TileView(create(), create());
writeln("HERE1b");
}
private TileView m_tileView;
}
unittest
{
auto v = View(5);
}
[/code]
[output]
HERE1a
HERE2
HERE1b
HERE2
[/output]
[expected_output]
HERE1a
HERE1b
HERE2
[/expected_output]