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

* [Bug c++/48884] decltype's operand doesn't consider friend declaration
  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 ` redi at gcc dot gnu.org
  2011-05-23 19:47 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-05 12:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48884

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.05 12:35:32
     Ever Confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-05 12:35:32 UTC ---
confirmed

if Y::f is not a template then access checking succeeds

here's a C++03 version, which fails in the same way:

class X
{
    int value ;
    friend class Y ;
} ;

template <int> struct Int { };

class Y
{
public :
    template < typename T >
    static Int<sizeof(T::value)> f(T t)
    {
        return Int<sizeof(t.value)>();
    }
} ;

int main()
{
    X x ;
    Y::f(x) ; // gcc issues error
}


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

* [Bug c++/48884] decltype's operand doesn't consider friend declaration
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-23 19:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48884

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/48884] decltype's operand doesn't consider friend declaration
  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
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-24 20:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48884

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-24 20:26:51 UTC ---
Author: jason
Date: Tue May 24 20:26:47 2011
New Revision: 174139

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174139
Log:
    PR c++/48884
    * class.c (pushclass): Accept NULL argument.
    (popclass): Deal with popping null class.
    * pt.c (push_access_scope, pop_access_scope): Use them rather than
    push_to_top_level/pop_from_top_level.
    (push_deduction_access_scope, pop_defarg_context): New.
    (fn_type_unification): Use them.
    * name-lookup.c (lookup_name_real_1): Check current_class_type.

Added:
    trunk/gcc/testsuite/g++.dg/template/access21.C
    trunk/gcc/testsuite/g++.dg/template/access22.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/48884] decltype's operand doesn't consider friend declaration
  2011-05-05 12:03 [Bug c++/48884] New: decltype's operand doesn't consider friend declaration boostcpp at gmail dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-25  1:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48884

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-25 01:08:48 UTC ---
Author: jason
Date: Wed May 25 01:08:46 2011
New Revision: 174163

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174163
Log:
    PR c++/48884
    * pt.c (fn_type_unification): Disable access control during
    substitution.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/template/access21.C
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/template/access22.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/pt.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug c++/48884] decltype's operand doesn't consider friend declaration
  2011-05-05 12:03 [Bug c++/48884] New: decltype's operand doesn't consider friend declaration boostcpp at gmail dot com
                   ` (3 preceding siblings ...)
  2011-05-25  1:36 ` jason at gcc dot gnu.org
@ 2011-05-25  1:45 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-25  1:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48884

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.6.1

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-25 01:18:52 UTC ---
Fixed for 4.6.1.


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