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++/48884] New: decltype's operand doesn't consider friend declaration


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: unassigned@gcc.gnu.org
        ReportedBy: boostcpp@gmail.com


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>.


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