public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pi3orama at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/42063] New: g++ violate [class.dtor] when explicit destructor call Date: Mon, 16 Nov 2009 05:25:00 -0000 [thread overview] Message-ID: <bug-42063-18401@http.gcc.gnu.org/bugzilla/> (raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1600 bytes --] This bug is related to the example in [class.dtor]/12 of standard N2960. according to the example, in the following program: #include <iostream> struct B { virtual ~B() { std::cout << "~B" << std::endl; } }; struct D : B { ~D () { std::cout << "~D" << std::endl; } }; typedef B B_alias; int main() { D D_object; B* B_ptr = &D_object; std::cout << "begin" << std::endl; D_object.B::~B(); B_ptr->~B(); std::cout << "end" << std::endl; return 0; } D_object .B::~B () should call B¡¯s destructor, and B_ptr ->~B () should call D's destructor. However the actual result is begin ~B ~B end ... the strange thing is when D_object.B::~B() be removed, or be swapped between B_ptr->~B(), everything is OK. Another problem: according to the spec, 'Once a destructor is invoked for an object, the object no longer exists'. However, the following code shows that g++ doesn't respect it: #include <iostream> struct C { ~C() { std::cout << "XXX" << std::endl; } }; int main() { C * c = new C(); c->C::~C(); delete c; return 0; } the program ends normally. Shouldn't it generate a double free fault? -- Summary: g++ violate [class.dtor] when explicit destructor call Product: gcc Version: 4.3.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pi3orama at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42063
next reply other threads:[~2009-11-16 5:25 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2009-11-16 5:25 pi3orama at gmail dot com [this message] 2009-11-16 13:17 ` [Bug c++/42063] " paolo dot carlini at oracle dot com 2009-11-16 13:59 ` paolo dot carlini at oracle dot com 2009-11-17 10:02 ` redi at gcc dot gnu dot org
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-42063-18401@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).