home *** CD-ROM | disk | FTP | other *** search
- #if 0
- From:
- Subject: Destructors not called right in || && expressions
- Status: Works in ZTC++ 2.18
- #endif
-
- // bug16.cpp
- // cfront: Sorry, not implemented...
- // Turbo C++: Calls constructor once, destructor 3 times
- // Zortech: Calls constructor once, destructor twice
-
- #include <stdio.h>
-
- struct X
- {
- X(int x) { printf("X(%d)\n",x); }
- ~X() { printf("~X()\n"); }
- };
-
- int f(X x) {return 0;}
-
- void main()
- {
- 1 && f(3); // Calls X(3) and ~X()
- 0 && f(3); // bug: calls destructor only
- 1 || f(3); // bug: calls destructor only
- }
-
-