This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23316] Unused copy constructor can't be private
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Aug 2005 13:53:35 -0000
- Subject: [Bug c++/23316] Unused copy constructor can't be private
- References: <20050810134759.23316.christian.engstrom@glindra.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-10 13:53 -------
Please read: http://gcc.gnu.org/gcc-3.4/changes.html:
When binding an rvalue of class type to a reference, the copy constructor of the class must be
accessible. For instance, consider the following code:
class A
{
public:
A();
private:
A(const A&); // private copy ctor
};
A makeA(void);
void foo(const A&);
void bar(void)
{
foo(A()); // error, copy ctor is not accessible
foo(makeA()); // error, copy ctor is not accessible
A a1;
foo(a1); // OK, a1 is a lvalue
}
-----
This is invalid and is rejected as expected.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23316