This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23842] New: [3.4/4.0/4.1 Regression] Incorrect access control context
- From: "jsm28 at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Sep 2005 20:22:15 -0000
- Subject: [Bug c++/23842] New: [3.4/4.0/4.1 Regression] Incorrect access control context
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
struct S;
extern S *p;
template<class T> int f(T*, int y = ((T*)p)->x) {
return y;
}
struct S {
private:
int x;
template<class U> friend int f(U*, int);
};
int g() {
return f(p);
}
compiles OK with 3.3, but is rejected by 4.1, 4.0 and 3.4:
t4.cc:8: error: 'int S::x' is private
t4.cc:12: error: within this context
According to Mark: This is a G++ bug. G++ is apparently performing access
control for the default argument expression for "y" (in the template function
"f") in the context of the instantiation, rather than in the context of the
template function. See [temp.inst] for details.
--
Summary: [3.4/4.0/4.1 Regression] Incorrect access control
context
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jsm28 at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23842