// this c++ code failes to compile under every gcc/g++ version I know...
#include<map> template<class T> class foo { private: static std::map<long, std::pair<T, long> > data; static long long lastId; public: foo () { refValid = false; } foo (const T & v) { lastId++; ref = data.insert (std::pair<long, std::pair<T, long> > (lastId, std::pair<T, long> (v, 0))).first; refValid = true; (*ref).second.second++; } foo (const foo<T> & v) { operator= (v); } ~foo () { end (); } void operator= (const foo<T> & v) { if (&v == this) return; end (); ref = v.ref; refValid = true; (*ref).second.second++; } private: // g++ fails here: std::map<long, std::pair<T, long> >::iterator ref; bool refValid; void end () { if (!refValid) return; (*ref).second.second--; refValid = false; } }; template<class T> std::map<long, std::pair<T, long> > foo<T>::data; template<class T> long long foo<T>::lastId = 0; int main () { foo<char> x; return 0; } -- Summary: Static variable typed the member type of another class Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kag at graf dot slask dot pl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33061