
Douglas Gregor wrote:
Oops, sorry! Brad King tracked down a problem with similar symptoms to what is happening with Signals, and got it down to this test case:
Thanks for the test case. But see below.
#include <stdio.h>
struct A { A() { printf("A(): %p\n", this); } A(const A&) { printf("A(const A&): %p\n", this); } ~A() { printf("~A(): %p\n", this); } };
struct B: public A { B() { printf("B(): %p\n", this); } B(const B& b): A(b) { printf("B(const B&): %p\n", this); } ~B() { printf("~B(): %p\n", this); } };
struct C { operator B () { printf("operator B()\n"); return B(); } };
void f(A) { printf("f()\n"); }
int main() { C c; f(c); return 0; }
IIRC, B::~B() doesn't get called properly for the temporary returned from operator C::B(), but you'll want to check that before you report anything.
cxx -version V6.5-042 main.cc && ./a.out operator B() A(): 11fffbfd0 B(): 11fffbfd0 A(const A&): 11fffbfd8 B(const B&): 11fffbfd8 <- ### f() ~A(): 11fffbfd8 ~B(): 11fffbfd0 ~A(): 11fffbfd0
cxx -version V7.1-006 main.cc && ./a.out operator B() A(): 11fffbfe0 B(): 11fffbfe0 A(const A&): 11fffbfe8 f() ~A(): 11fffbfe8 ~B(): 11fffbfe0 ~A(): 11fffbfe0
As you can see, the old compiler version creates an extraneous call to B's copy constructor. This is fixed in the latest release. Therefore I assume that this isn't the root of the problem we see in the signals tests, as the failures show up for both the latest Tru64/CXX compiler (which uses Comeau) and for Comeau on windows. Markus