------- Comment #4 from sipych at gmail dot com 2009-07-24 00:00 ------- // More similar cases. Static members also may be accessed
#include <iostream> class A { enum { value=1 }; // private static const int ci=2; static int fi() { return 3; } }; template <int i> // bug appears only if B is a template struct B { enum { value=A::value }; // <- silently access private member // enum { v2=A::ci }; // this error is detected @ any instantiation static const int v3=A::value; // not detected static const int v4=A::ci; // not detected static int f5() { return A::value; } // not detected static int f6() { return A::ci; } // detected only if f6() accessed static int f7() { return A::fi(); } // detected only if f7() accessed, reported twice }; int main() { std::cout << B<1>::value << B<1>::v3 << B<1>::v4 << B<1>::f5() // << B<1>::f6() // error will be detected // << B<1>::f7() // error will be detected, and reported TWICE << std::endl; return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40843