From: Andrew Pinski <pinskia@gmail.com>
To: Paul Koning <paulkoning@comcast.net>
Cc: GCC Development <gcc@gcc.gnu.org>
Subject: Re: Possible C++ method signature warning feature?
Date: Wed, 10 Aug 2022 18:25:47 -0700 [thread overview]
Message-ID: <CA+=Sn1n0phHFP_NFYECT-n4Qs5fUhOvaJm8FSK-r19C=Kj_SNw@mail.gmail.com> (raw)
In-Reply-To: <BED279A1-C0AB-4B6C-865A-2ED1D7A3EB59@comcast.net>
On Wed, Aug 10, 2022 at 6:20 PM Paul Koning via Gcc <gcc@gcc.gnu.org> wrote:
>
> There's a C++ problem I keep running into, in a very large body of software with lots of subclassing.
>
> There's a base class that defines a set of interface methods, not all pure virtual (some define the default behavior). A number of subclasses override some but not all of these.
>
> Now I find myself changing the argument list of some of these methods, so I have to change the base class definitions and also track down all the subclass redefinitions. If I miss one of the latter, that subclass method is no longer called (it now just looks like an unrelated method with a different argument list that isn't used anywhere). Finding these things can be hard and time consuming.
>
> It would be helpful to have some way to mark a method as "this is supposed to be an override of a base class method", in other words "warn me if this method doesn't override some method in a base class".
C++11's overload keyword sounds exactly what you want.
https://en.cppreference.com/w/cpp/language/override
Thanks,
Andrew Pinski
>
> Does that sound like a possible thing to do, perhaps with some __attribute__ magic? Would it be interesting?
>
> paul
>
next prev parent reply other threads:[~2022-08-11 1:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 1:18 Paul Koning
2022-08-11 1:25 ` Andrew Pinski [this message]
2022-08-11 13:00 ` Paul Koning
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+=Sn1n0phHFP_NFYECT-n4Qs5fUhOvaJm8FSK-r19C=Kj_SNw@mail.gmail.com' \
--to=pinskia@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=paulkoning@comcast.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).