public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2015-06-21 18:59 db0451 at gmail dot com
  2015-06-21 19:01 ` [Bug c++/66617] " db0451 at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: db0451 at gmail dot com @ 2015-06-21 18:59 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/66617] C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature
  2015-06-21 18:59 [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 db0451 at gmail dot com
@ 2015-06-21 19:01 ` db0451 at gmail dot com
  2015-06-21 19:22 ` db0451 at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: db0451 at gmail dot com @ 2015-06-21 19:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66617

--- Comment #1 from Daniel Boles <db0451 at gmail dot com> ---
Forgot to add the minimal replication steps mentioned, prepared by a fellow SO
users:

http://coliru.stacked-crooked.com/a/c4d031382115b59a

thanks


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/66617] C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature
  2015-06-21 18:59 [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 db0451 at gmail dot com
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: db0451 at gmail dot com @ 2015-06-21 19:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66617

Daniel Boles <db0451 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #35822|0                           |1
        is obsolete|                            |

--- Comment #2 from Daniel Boles <db0451 at gmail dot com> ---
Comment on attachment 35822
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35822
Original problem pattern

I think I got some files mixed up in the first upload. I am about to upload a
fixed zip; please refer to that instead. However, the main text is the key
thing :-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/66617] C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature
  2015-06-21 18:59 [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 db0451 at gmail dot com
  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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: db0451 at gmail dot com @ 2015-06-21 19:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66617

--- Comment #3 from Daniel Boles <db0451 at gmail dot com> ---
Created attachment 35824
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35824&action=edit
3 cpp files showing various permutations from totally broken braces, to fully
working parentheses

Revised version as I had saved a wrong file version in the last upload.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/66617] C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature
  2015-06-21 18:59 [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 db0451 at gmail dot com
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: db0451 at gmail dot com @ 2015-06-24 18:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66617

--- Comment #5 from DB <db0451 at gmail dot com> ---
Created attachment 35847
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35847&action=edit
-save-temps output files plus the triggering cpp file

see corresponding -v output added in latest comment. Please advise when this
issue has been received and reviewed. Thanks.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/66617] C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature
  2015-06-21 18:59 [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 db0451 at gmail dot com
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-06-25 13:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66617

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-06-25
     Ever confirmed|0                           |1

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Probably related to PR55922.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/66617] C++11 {brace} initialisation of virtually inherited derived class = failure to override base virtual function, unless all base ctors have same signature
  2015-06-21 18:59 [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 db0451 at gmail dot com
                   ` (4 preceding siblings ...)
  2015-06-25 13:53 ` redi at gcc dot gnu.org
@ 2015-07-12 13:48 ` db0451 at gmail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: db0451 at gmail dot com @ 2015-07-12 13:48 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66617

--- Comment #7 from DB <db0451 at gmail dot com> ---
I just found a similar, possibly related issue with {brace} ctor call and
access specifiers

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66847

As mentioned in the comment there, we're looking forward to movement on these
so that we can properly migrate to the C++11 syntax. Currently we have to
selectively use (parentheses) in certain places to work around these issues
with (the otherwise flawless) G++.

Thanks,
D.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-07-12 13:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-21 18:59 [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 db0451 at gmail dot com
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

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).