...ing logging 4.0

はてなブログに移行しました。D言語の話とかいろいろ。

デストラクタはプログラム終了時に呼ばれるのか

via. http://d.hatena.ne.jp/yukkepc/20081119/1227056997

>type a.d
import std.stdio;
class a {
  ~this() { writefln("destructor"); }
  static ~this() { writefln("static destructor"); }
}
void main() {
  auto a = new a();
}

>bud a

>a
static destructor
destructor

dmd 2.020 + phobos だったらちゃんとデストラクタが呼ばれるけど?
多分プログラム終了時にはデストラクタが呼ばれる仕様だったと思うけどなあ.
バグじゃないかな.
一応後で仕様読み直してみよう.