C++ Logo


Advanced search

Re: [std-proposals] enable very strict use of 'virtual', 'override', etc.

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Tue, 2 May 2023 11:17:09 -0400
On Tue, May 2, 2023 at 11:01 AM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> On Tuesday, 2 May 2023 07:21:05 PDT Frederick Virchanza Gotham via Std-
> Proposals wrote:
> > If the compiler would enforce these rules, it would be easier to clean
> > up old code.
> The original virtual override-marking proposal back before C++11 had such
> things. It was dropped and updated to only have the override and final
> contextual keywords.
> Your proposal needs to reflect back to that proposal, explain how it's different
> from it and avoids the mistakes that doomed that proposal.

One problem with that is that it is generally quite difficult to find
that sort of information without directly asking one of the people who
were there. Particularly in the early days, the record of discussions
about proposals was pretty thin. Things are a bit better nowadays, but
it's still not exactly easy.

For this particular case, N3206 is pretty much the most you can find
in the record for when most of the functionality was dropped (and
there are some parts of that which also were dropped, like `new`). And
it is not exactly enlightening about the *motivation* for the changes.
It makes reference to "FCD National Body comments US 44 and CA 3 on
2010-11-10, 2010-11-11, and 2010-11-12", but even those don't say much
about the rationale.

> We also now have
> over 10 years of experience with the current keywords, so you need to reflect
> the state of the art and how compilers warn these days (the "inconsistent use
> of override" warning).

Those aren't warnings; it is ill-formed to use `override` on a
function declaration that doesn't match a virtual base class
equivalent ([class.virtual]/5, from C++20).

Received on 2023-05-02 15:17:21