The following code compiles with gcc 3.2.3 and the current Comeau compiler.
However it fails with gcc 4.1.2 and gcc 4.2.3.

class A
{
public:
    A(bool) {};
private:
    A(const A&);
};

class B
{
public:
    B(const A&) {};
};

int main(void)
{
    B b(A(true));
    return 0;
}

Gives this error message:

test.cpp: In function ‘int main()’:
test.cpp:6: error: ‘A::A(const A&)’ is private
test.cpp:17: error: within this context

I don't see where the code above would need a copy constructor for class A.
Making the copy constructor of A public without implementing it makes the code
compile.


-- 
           Summary: Copy constructor not used but required
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: peter dot klotz at aon dot at
  GCC host triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36393

Reply via email to