http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52816
Bug #: 52816 Summary: Access to private members inside decltype in the signature of a member template causes access control error Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: jewil...@osl.iu.edu When using decltype inside the return type of a member function template, I receive access control errors for references to private member variables. Here is a simple example of a failing program: class c { int f; public: template <typename A> decltype(f) m(A) const; }; decltype(c{}.m(0)) i; The use of old- vs. new-style function declarations does not change the behavior; neither does whether the class itself is a template. The error I get from GCC 4.7.0 is: test.cpp:2:7: error: ‘int c::f’ is private test.cpp:8:20: error: within this context I think that is likely to be incorrect since the reference to f is from inside the body of the class definition itself.