http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50184
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code Status|UNCONFIRMED |NEW Last reconfirmed| |2011-08-25 Ever Confirmed|0 |1 Known to fail| |4.1.2, 4.4.3, 4.5.2, 4.6.1, | |4.7.0 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-08-25 10:12:21 UTC --- (that code is actually invalid and g++ should reject it because CData::CItem is private in B's constructor, but there's a g++ bug that doesn't do access checking for template arguments, and fixing that doesn't prevent the segfault) reduced: #include <map> #include <string> using namespace std; struct CData { struct CItem { string m_str1; }; map<string, CItem> m_map; std::string m_strDFName; int m_nDFMsgTimeout; }; CData func() { CData data; data.m_map["Test"].m_str1 = "Data"; return data; } class B : public CData { public: B() : CData(func()) { std::string s; map<string, CItem>::iterator it = m_map.begin(); for (; it != m_map.end(); it++) // loops past the end { s += it->second.m_str1 + it->first;; } } }; int main() { B b1; return 0; }