The following code compiles on g++ 4.9.2 while it shouldn't. Accessing private members and access in non-templates are properly checked. However, a function template can actually access any private sub-class without being a friend. This problem exist for all standards I've tried ((gnu|c)++(98|03|11|14)) The code is properly rejected by clang++ 3.5.0. ``` // class C { struct T2 { }; static void f() {} }; template<typename T> static inline void f(T) { // C::f(); // This generates an error correctly C::T2 __attribute__((unused)) v2; // This does not generate an error } int main() { // C::T2 v2; // This also generates an error correctly f(1); return 0; } ```
Almost certainly a duplicate of one of the bugs linked to PR59002, it looks nearly identical to PR41437
Definitely a dup *** This bug has been marked as a duplicate of bug 41437 ***