This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/23316] Unused copy constructor can't be private


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]