public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37775]  New: Templated private class visible through friend declaration
@ 2008-10-08 20:48 sam at gcc dot gnu dot org
  2009-01-16  3:50 ` [Bug c++/37775] " jason at gcc dot gnu dot org
  2009-10-02 21:39 ` sam at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-10-08 20:48 UTC (permalink / raw)
  To: gcc-bugs

The following example compiles cleanly with g++, while I think the "friend"
declaration should be rejected, as the templated private class "A::Inner"
should not be visible except from within A.

#include <iostream>

class A {
  public:
    static int h();
  private:
    template<typename T>
    struct Inner {
      static int f();
    };
};

class B {
  friend class A::Inner<int>;   // Should not be visible
  static int g() { return 42; }
};

template<>
int A::Inner<int>::f()
{
  return B::g();
}

int A::h()
{
  return Inner<int>::f();
}

int main()
{
  std::cout << A::h() << std::endl;
}


-- 
           Summary: Templated private class visible through friend
                    declaration
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sam at gcc dot gnu dot org
  GCC host triplet: x86_64-unknown-linux-gnu


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


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

* [Bug c++/37775] Templated private class visible through friend declaration
  2008-10-08 20:48 [Bug c++/37775] New: Templated private class visible through friend declaration sam at gcc dot gnu dot org
@ 2009-01-16  3:50 ` jason at gcc dot gnu dot org
  2009-10-02 21:39 ` sam at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-01-16  3:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jason at gcc dot gnu dot org  2009-01-16 03:50 -------
11.4: A name nominated by a friend declaration shall be accessible in the scope
of the class containing the friend declaration.

Confirmed.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-01-16 03:50:16
               date|                            |


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


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

* [Bug c++/37775] Templated private class visible through friend declaration
  2008-10-08 20:48 [Bug c++/37775] New: Templated private class visible through friend declaration sam at gcc dot gnu dot org
  2009-01-16  3:50 ` [Bug c++/37775] " jason at gcc dot gnu dot org
@ 2009-10-02 21:39 ` sam at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: sam at gcc dot gnu dot org @ 2009-10-02 21:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sam at gcc dot gnu dot org  2009-10-02 21:38 -------
Reconfirmed on SVN trunk: gcc (GCC) 4.5.0 20090930 (experimental)


-- 


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


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

end of thread, other threads:[~2009-10-02 21:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-08 20:48 [Bug c++/37775] New: Templated private class visible through friend declaration sam at gcc dot gnu dot org
2009-01-16  3:50 ` [Bug c++/37775] " jason at gcc dot gnu dot org
2009-10-02 21:39 ` sam at gcc dot gnu dot 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).