This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19249] abstract classes should not access virtually inherited class constructor
- From: "jkanze at cheuvreux dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jan 2005 14:29:59 -0000
- Subject: [Bug c++/19249] abstract classes should not access virtually inherited class constructor
- References: <20050104053610.19249.gianni@mariani.ws>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From jkanze at cheuvreux dot com 2005-01-05 14:29 -------
The context of the quote from the standard is:
"If the constructor of the most derived class does not
specify a mem-initializer for the virtual base class
V ...". In the code submitted, the constructor of the
most derived class DOES specify a mem-initializer, so
none of what follows applies.
I think that there is a bit of history at play here.
All compilers I know reject the code, I suspect because
CFront rejected it, and nobody noticed that CFront was
in error here.
Note that the absence of a default initializer, when
it is required, is undefined behavior, so a trivial fix
would be to replace the call to the (non-existing)
constructor in the in-charge constructor with a call
to a function which displays an error message and calls
abort. A better fix would be to not generate the in-charge
constructor at all, resulting in a linker error if the class
was ever instantiated. (Not possible here, since the class is
abstract, but possible in the more general case.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19249