Depending on whether the copy constructor CA(const CA& a) (see following code) is private, public or not (explicitly) defined the constructor CA(const SA& a) from the unrelated class SA gets compile errors. It compiles for public and undefined, but not for private. If CA(const CA& a) is public, the code compiles and runs as expected, and CA(const CA& a) is not executed (but somehow needed for compilation?!). ---
on SuSe linux 10.0 with ~/wurschtel/cpp> uname -a Linux djebe 2.6.13-15-smp #1 SMP Tue Sep 13 14:56:15 UTC 2005 i686 i686 i386 GNU/Linux and gcc 4.0.2 (but also with 4.1.2) the code (file y.cpp) ----- //originally from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13478, modified #include <iostream> using namespace std; class SA { }; class CA { public: CA() { cout << "CA()" << endl; }; CA(const SA& a) { cout << "CA(const SA& a)" << endl; }; private: CA(const CA& a) { cout << "CA(const CA& a)" << endl; }; }; void foo(const SA& pa) { const CA ra=CA(pa); } int main (int argc, char* argv[]) { const SA* pa = new SA(); const CA pb(*pa); foo(*pa); } ----- gives compile errors: g++ -ansi -pedantic -Wall -o y y.cpp y.cpp: In function ‘void foo(const SA&)’: y.cpp:27: error: ‘CA::CA(const CA&)’ is private y.cpp:37: error: within this context y.cpp:27: error: ‘CA::CA(const CA&)’ is private y.cpp:37: error: within this context [EMAIL PROTECTED]:~/wurschtel/cpp> -- Summary: copy consturctor influences compile errors of constructor from unrelated class Product: gcc Version: 4.0.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sl at datamyway dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30959