mvm@jedi.harris-atd.com (Matt Mahoney) (08/27/90)
Does anyone know of a C++ compiler that handles code like:
String s;
if (s == "something" || s == "something else") // error
Turbo C++ 1.0, Zortech 2.1, and Sun C++ 2.0 (a cfront port) all fail
to handle temporary objects with destructors in && or || expressions.
Here is a more complete example:
// cfront: Sorry, not implemented...
// Turbo C++: Calls constructor once, destructor 3 times
// Zortech: Calls constructor once, destructor twice
struct X
{
X(int x) {cout << "X(" << x << ")\n";}
~X() {cout << "~X()\n";}
};
int f(X x) {return 0;}
main()
{
1 && f(3); // Calls X(3) and ~X()
0 && f(3); // bug: calls destructor only
1 || f(3); // bug: calls destructor only
}
---------------------------------------------------
Matt Mahoney, (407) 727-5431, mvm@epg.harris.com, mvm@trantor.harris-atd.com
#include <disclaimer.h> // <disclaimer.hpp> in Zortech
// <iodisclaimer.h> in Turbo