public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/50184] Segmentation fault. Copy Constructor. Date: Thu, 25 Aug 2011 10:24:00 -0000 [thread overview] Message-ID: <bug-50184-4-iSGDNdXj3U@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-50184-4@http.gcc.gnu.org/bugzilla/> 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; }
next prev parent reply other threads:[~2011-08-25 10:12 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-08-25 9:02 [Bug c++/50184] New: " EugeneSm at yandex dot ru 2011-08-25 9:16 ` [Bug c++/50184] " EugeneSm at yandex dot ru 2011-08-25 10:24 ` redi at gcc dot gnu.org [this message] 2011-08-25 11:14 ` redi at gcc dot gnu.org 2015-08-24 12:07 ` zeccav at gmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-50184-4-iSGDNdXj3U@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).