This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21917] Missing warning when trying to explicitly construct a virtual base
- From: "r_q_einstein-gccgnuorg at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Jun 2008 23:07:12 -0000
- Subject: [Bug c++/21917] Missing warning when trying to explicitly construct a virtual base
- References: <bug-21917-6594@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from r_q_einstein-gccgnuorg at yahoo dot com 2008-06-05 23:07 -------
I've run across this, too.
I agree with Ivan's 2005-06-04 suggestion.
It would be nice if the compiler would emit a warning that the derived class's
constructor's call to the virtual base class's non-default constructor is being
ignored and overridden by an implicit call to the virtual base class's default
constructor.
Similarly, if the virtual base class fails to specify a default constructor
(and specifies only a non-default one), the derived class's constructor's call
to the virtual base class's non-default constructor produces only this error
message:
In constructor 'top::top()':
error: no matching function for call to 'virt::virt()'
which leaves the developer scratching his/her head if he doesn't know that the
C++ spec. requires virtual base classes to have default constructors. (True,
s/he should know, but the compile error message could be more helpful.)
Something to the effect of:
"virtual base class lacks default constructor" would be much more helpful.
If this issue is different enough to warrant a separate "bug" report, let me
know and I'll be happy to file it separately.
Thanks.
--
r_q_einstein-gccgnuorg at yahoo dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |r_q_einstein-gccgnuorg at
| |yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21917