If one instance of an overloaded function or operator is generic, I cannot supply a member of an anonymous enum to that function or operator, even if I wouldn't be calling the generic instance anyway. As an example of the problem, attempting to compile the simplified code class S; template <typename T> S& operator<< (S&, const T&); enum { x }; static const int xx = 1 << x; with G++ 4.0.0 fails with the error anonenum.cc:5: error: '<anonymous enum>' is/uses anonymous type anonenum.cc:5: error: trying to instantiate 'template<class T> S& operator<<(S&, const T&)' This is a regression over previous versions, which have no problem with such code. (Neither do other vendors' compilers.) It is obviously trivial to work around the bug by naming the enum, but I believe I shouldn't need to.
The code is invalid, see PR 19404 and PR 20589 *** This bug has been marked as a duplicate of 19404 ***