[Bug c++/21917] Missing warning when trying to explicitly construct a virtual base
r_q_einstein-gccgnuorg at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 5 23:07:00 GMT 2008
------- 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
More information about the Gcc-bugs
mailing list