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.

Reply via email to