---------- code: import std.stdio; class A { int v_; this( int v ) { v_ = v; } ~this() { writeln( "dtor called: ", v_ ); } } void f() { scope A a = new A( 4 ); delete a; if( a is null ) writeln( ">>> a4 is null" ); a.v_ = 500; writeln( "a.v_ == ", a.v_ ); } void main() { f(); writeln( "end main" ); } ---------- output: dtor called: 4 a.v_ == 500 end main "a" must be null after delete.. is this behavior correct ?
There would be no way to ensure this, since it would be trivial to just copy the reference to the class and use that instead. In general, accessing `delete`d ressources is UB. Just like accessing `free`d memory. Moreover, `delete` have been deprecated, so I'm going to close this as WONTFIX.