[Bug c++/23842] New: [3.4/4.0/4.1 Regression] Incorrect access control context
jsm28 at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Sep 12 20:22:00 GMT 2005
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
More information about the Gcc-bugs
mailing list