public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105752] New: Template function can access private member
@ 2022-05-27 16:36 csaba_22 at yahoo dot co.uk
  2022-05-27 16:40 ` [Bug c++/105752] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: csaba_22 at yahoo dot co.uk @ 2022-05-27 16:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105752
           Summary: Template function can access private member
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: csaba_22 at yahoo dot co.uk
  Target Milestone: ---

The following code

class Outer
{
private: //  !!!!!
    struct Inner
    {};
};

template<typename T>
struct Meow
{
    void purr() {
        Outer::Inner oi;
    }
};

int main()
{
    Meow<double> kitty;
    //kitty.purr();
}

is compiled by GCC from 4.1.2 to 12.1.0, but is rejected by all clang releases 
 available on godbolt.

https://godbolt.org/z/58Yca6dah

Also mentioned here:
https://stackoverflow.com/questions/28596242/accessing-private-inner-class-type-from-non-member-template-function

If the call to the function is uncommented, then GCC also emits an error.

Visual Studio 2013 update 4 also  emits an  error (allegedly), so this sounds
like a bug.

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

end of thread, other threads:[~2022-06-02 13:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 16:36 [Bug c++/105752] New: Template function can access private member csaba_22 at yahoo dot co.uk
2022-05-27 16:40 ` [Bug c++/105752] " pinskia at gcc dot gnu.org
2022-05-27 17:12 ` redi at gcc dot gnu.org
2022-05-27 17:13 ` redi at gcc dot gnu.org
2022-05-30 17:49 ` csaba_22 at yahoo dot co.uk
2022-06-02  9:10 ` csaba_22 at yahoo dot co.uk
2022-06-02 13:29 ` 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).