Source:
#include <iostream.h>
class foo {
public:
static bar() { cout << "bar ";}
foo() {cout << "ctor ";}
~foo() {cout << "dtor\n";}
};
void main()
{
foo().bar();
}
Output
bar dtor
Destructor was called without calling the
constructor. This was reported in
Windows Development Journal with comments by Ron
Burk years ago and
now I think only
DMC++ still has this bug.
GNU saying "bar" - perhaps the optimisation
is too wonderful to be true...
VC++ and BCC32 says "ctor bar dtor" which object was created and destroyed.