in reply to Detect a localized variable

Huge code smell, accessing that global state. Can't you use something sane, like a instance destructor or Scope::Guard?