[Bug c++/61816] New: Member functions of a template class can access private classes without permission

myriachan at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jul 16 00:23:00 GMT 2014


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

            Bug ID: 61816
           Summary: Member functions of a template class can access
                    private classes without permission
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: myriachan at gmail dot com
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu

There exists a case in which a member function of a forward-declared template
can access a private inner class without permission.  Possible duplicate of bug
41437.


class ClassWithEverythingPrivate {
    class InnerClass {
    public:
        static int InnerFunction() {
            return 123;
        }
    };
};

template <typename T> class TemplateClass {
public:
    static int StaticFunction() {
        return ClassWithEverythingPrivate::InnerClass::InnerFunction();
    }
};

int main() {
    return TemplateClass<void>::StaticFunction();
}



More information about the Gcc-bugs mailing list