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++/15254] friend function does not have access to private method in templeted classes


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-03 04:44 -------
It is not ignoring the friend at all.  Did you notice that the error is about access in main?
Basically the access is required by the standard to be in that context.  And no I was not talking about 
the quote you gave from changes.html but
"
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 might be surprising at first sight, especially since most popular compilers do not correctly 
implement this rule  (further details <http://gcc.gnu.org/bugs.html#cxx_rvalbind>).
"

Which is why I gave the second reference.

So making a tempary variable is what you need to do.

-- 


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


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