public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mendola at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55449] New: [4.4.3] pure virtual call only with -O1/2/3 (boost::optional) Date: Fri, 23 Nov 2012 15:44:00 -0000 [thread overview] Message-ID: <bug-55449-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55449 Bug #: 55449 Summary: [4.4.3] pure virtual call only with -O1/2/3 (boost::optional) Classification: Unclassified Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: mendola@gmail.com Created attachment 28765 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28765 test case + preprocessor output The following code generates a pure virtual method call only when compiled with -O1/O2/O3, the same code seems working without error with gcc 4.7.3. The code is inlined in here and I have attached an archive containing the preprocessor output as well. Consider that it doesn't crash if: - Remove the noncopyable from B or - Remove one of the two segments in the extra scope in main or - Remove the try { } catch I have tried with boost 1.40, 1.50 and 1.52 #include <boost/optional.hpp> #include <boost/noncopyable.hpp> class B : boost::noncopyable { //if the noncopyable is removed works public: virtual size_t bar() const = 0; }; class D : public B { public: D() :theBar(foo(10)) { } virtual size_t bar() const { return theBar; } private: static size_t foo(const boost::optional<size_t> a) { if (a) { //if this is a.is_initialized() then it works return a.get(); } return 2; } const size_t theBar; }; class Foo { public: Foo(const B& b) :theBar(b.bar() * b.bar()) { } private: const size_t theBar; }; int main() { { //if this section is removed works D d; try { Foo myCompound(d); } catch(...) {} } { D d; try { Foo myCompound(d); } catch(...) {} } }
next reply other threads:[~2012-11-23 15:44 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-23 15:44 mendola at gmail dot com [this message] 2012-11-23 16:06 ` [Bug c++/55449] " redi at gcc dot gnu.org 2012-11-23 16:11 ` paolo.carlini at oracle dot com 2012-11-24 6:28 ` mendola at gmail dot com 2012-11-24 6:37 ` pinskia at gcc dot gnu.org 2012-11-24 6:57 ` mendola at gmail dot com 2012-11-24 9:43 ` paolo.carlini at oracle dot com 2012-11-24 12:03 ` redi at gcc dot gnu.org 2012-11-24 12:25 ` mendola at gmail dot com 2012-11-24 14:21 ` redi at gcc dot gnu.org 2012-11-24 17:49 ` mendola 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-55449-4@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).