http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48884
Summary: decltype's operand doesn't consider friend declaration
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
decltype's operand doesn't consider friend declaration if it's used as a return
type of the function.
Following code failed.
class X
{
int value ;
friend class Y ;
} ;
class Y
{
public :
template < typename T >
static auto f(T t) -> decltype( t.value )
{
return t.value ; // OK. Y is a friend of X.
}
} ;
int main()
{
X x ;
Y::f(x) ; // gcc issues error
}
The error message is
In function 'int main()':
error: 'int X::value' is private
error: within this context
It looks like access checking is done in the main rather than Y::f<X>.