This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15254] friend function does not have access to private method in templeted classes
- 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: 3 May 2004 04:44:34 -0000
- Subject: [Bug c++/15254] friend function does not have access to private method in templeted classes
- References: <20040503023217.15254.hyliviu-gcc@yahoo.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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