public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48884] New: decltype's operand doesn't consider friend declaration
@ 2011-05-05 12:03 boostcpp at gmail dot com
  2011-05-05 12:40 ` [Bug c++/48884] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: boostcpp at gmail dot com @ 2011-05-05 12:03 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-25  1:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05 12:03 [Bug c++/48884] New: decltype's operand doesn't consider friend declaration boostcpp at gmail dot com
2011-05-05 12:40 ` [Bug c++/48884] " redi at gcc dot gnu.org
2011-05-23 19:47 ` jason at gcc dot gnu.org
2011-05-24 20:44 ` jason at gcc dot gnu.org
2011-05-25  1:36 ` jason at gcc dot gnu.org
2011-05-25  1:45 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).