public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110037] New: GCC accepts private member access of enclosing through friend function of inner class
@ 2023-05-30 10:37 jlame646 at gmail dot com
  2023-05-30 12:33 ` [Bug c++/110037] GCC accepts private member access of enclosing class " ppalka at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: jlame646 at gmail dot com @ 2023-05-30 10:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110037

            Bug ID: 110037
           Summary: GCC accepts private member access of enclosing through
                    friend function of inner class
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following program is accepted by gcc and clang:
https://godbolt.org/z/Gs479M4Tf

```
template <typename T>
class Outer
{
public:
  struct Inner {
    friend bool operator==(const Inner& a, const Inner& b) {
      return a.outer_.private_member_ == b.outer_.private_member_;
    }

  Inner(Outer<T> & o):outer_{o} 
  {

  }
   private:
    Outer<T>& outer_;

  };
  friend struct Iterator;
 //friend bool operator==(const Inner& a, const Inner& b);
  private:
  int private_member_;
};

bool test(Outer<int>::Inner A, Outer<int>::Inner B)
{
    return A == B;
}

int main()
{
    Outer<int> o; 
    Outer<int>::Inner i(o); 
    Outer<int>::Inner j(o);
    if(i==j){}  
}
```

[class.nest#4] makes this ill-formed.

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

* [Bug c++/110037] GCC accepts private member access of enclosing class through friend function of inner class
  2023-05-30 10:37 [Bug c++/110037] New: GCC accepts private member access of enclosing through friend function of inner class jlame646 at gmail dot com
@ 2023-05-30 12:33 ` ppalka at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-30 12:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110037

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
dup

*** This bug has been marked as a duplicate of bug 106756 ***

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

end of thread, other threads:[~2023-05-30 12:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 10:37 [Bug c++/110037] New: GCC accepts private member access of enclosing through friend function of inner class jlame646 at gmail dot com
2023-05-30 12:33 ` [Bug c++/110037] GCC accepts private member access of enclosing class " ppalka 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).