<div class="gmail_quote">On Mon, Aug 15, 2011 at 02:14, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mon, Aug 15, 2011 at 1:31 AM, David Röthlisberger <<a href="mailto:david@rothlis.net">david@rothlis.net</a>> wrote:<br>
> In C++ when you have the following inheritance hierarchy:<br>
><br>
> Base <--(virtual)-- Middle <---- Derived<br>
><br>
> if Base has no default constructor, then the most-derived class must explicitly call the virtual base's constructor.<br>
><br>
> Clang's current error message is:<br>
><br>
> constructor for 'Derived' must explicitly initialize the base class 'Base'<br>
> which does not have a default constructor<br>
><br>
> Maybe I'm a bit slow, but when I encountered this error I spent about an hour trying to figure out why my initialization of Base in Middle's constructor wasn't being found. This patch adds the following note:<br>
><br>
> note: because 'Base' is a virtual base, the most-derived class must explicitly<br>
> initialize it<br>
><br>
> Is this a good idea? Unnecessary? Is it really clang's job to educate the user on the more obscure aspects of C++? (I would argue that yes, we need all the help we can get.)<br>
<br>
</div>I think a more subtle approach might be more appropriate: we could<br>
change to existing diagnostic to explicitly say "virtual base class"<br>
instead of just "base class". Hopefully, that would be enough to<br>
point the user in the right direction.<br>
<br>
-Eli<br></blockquote><div><br>I can't think of any reason we shouldn't have a note showing where it is virtual.<br><br>Sean<br></div></div>