[Issue 10789] Struct destructor erroneously called
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 10 00:44:29 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10789
Maxim Fomin <maxim at maxim-fomin.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maxim at maxim-fomin.ru
--- Comment #2 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-08-10 00:44:27 PDT ---
Reduced:
extern(C) int printf(const char*, ...);
struct S {
static int count;
this(int ignoreme)
{
int oldcount = count;
printf("%X ctor %d=>%d\n", &this, oldcount, ++count);
}
~this()
{
int oldcount = count;
printf("%X dtor %d=>%d\n", &this, oldcount, --count);
}
this(this)
{
int oldcount = count;
printf("%X postblit %d=>%d\n", &this, oldcount, ++count);
}
}
S fun()
{
S s1 = S(42), s2 = S(24);
if (true) return s1;
else return s2;
}
void main()
{
S s = fun();
}
In case of if(true) compiler does not insert postblit call.
--
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