public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "db0451 at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66617] New: C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature Date: Sun, 21 Jun 2015 18:59:00 -0000 [thread overview] Message-ID: <bug-66617-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66617 Bug ID: 66617 Summary: C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: db0451 at gmail dot com Target Milestone: --- Created attachment 35822 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35822&action=edit Original problem pattern Example steps: Create the following struct hierarchy: A > > C v v B With => struct A containing a pure virtual function => B and C taking public virtual inheritance from A. Now create struct D inheriting from B and C and implementing the pure virtual function. This will not work when D initialises its base classes using the new {brace} initialisation UNLESS, and only if, all base constructors have the same function signature/number of arguments. => Pure virtual function in base generates errors about being unable to allocate abstract classes B and C => Non-pure vfunc generates undefined references to the pure vfunc in B and C. Contructing D using (parentheses) initialisation works fine and leads to the expected result. This is as simple as replacing the brackets in the instantiation, nothing more. Supporting evidence are: => original thread on StackOverflow, by my handle @underscore_d - containing original problem code using {brace} initialisation as attached in "virtual2.cpp" - with working example (same ctor signatures) "virtual3.cpp" ====> http://stackoverflow.com/questions/30967490/virtual-inheritance-pure-v-function-in-base-fails-with-abstract-pure-error?noredirect=1#comment49967008_30967490 => minimal replication steps outlined by fellow SO user @0x499602D2 Attached also is "virtual4.cpp", which as mentioned, is merely "virtual2.cpp" with the instantiation of the final derived class changed to use (parenthesis) initialisation instead of {braces} Using G++ 4.9.2 from MSYS2 64-bit, latest version I was able to find. Many thanks Daniel B.
next reply other threads:[~2015-06-21 18:59 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-06-21 18:59 db0451 at gmail dot com [this message] 2015-06-21 19:01 ` [Bug c++/66617] " db0451 at gmail dot com 2015-06-21 19:22 ` db0451 at gmail dot com 2015-06-21 19:24 ` db0451 at gmail dot com 2015-06-24 18:57 ` db0451 at gmail dot com 2015-06-25 13:53 ` redi at gcc dot gnu.org 2015-07-12 13:48 ` db0451 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-66617-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).