<div dir="ltr"><div>Can anyone illuminate me as to where this destructor call is coming from?</div><div></div><div><br>struct Thing<br>{<br> static int x;<br> this(typeof(null)) pure {} // <-- comment this line and the error goes away<br> ~this() { ++x; }<br>}<br><br>Thing fun() pure<br>{<br> return Thing(null);<br>}<br></div><div><br></div><div>error : `pure` function `urt.string.string.fun` cannot call impure destructor `urt.string.string.Thing.~this`</div><div><br></div><div>Shouldn't NVRO construct the result in place and elide the copy/move? I would not expect any call to the destructor in fun()...<br></div><div>Also surprisingly, if I comment out the constructor, the compile error about the destructor goes away. I can't see why the constructor's existence affects the destruction semantics in fun()?<br>
</div></div>