From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id C3A1C3857B98 for ; Thu, 11 Aug 2022 01:26:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C3A1C3857B98 Received: by mail-pg1-x52a.google.com with SMTP id 12so15885384pga.1 for ; Wed, 10 Aug 2022 18:26:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc; bh=m0elTo1ZqG+SKdYVojmxFvP7AbSKlG88QvLNQrcfKVQ=; b=H58zv0NGbZbySLeNc92ycUD3Ev64pgfTh2R9QjiIqDLH6ZWxF4WRh3MH43x/MYbSvm MeNcb6XDXj5MgPX/c/Nm1equmyFGdCPUD0N2De6Bqd3dp/+E6gim5fHLdltjR5XNcQ9e qO6JS72J1E+n2p9Qc+U1pzrzu7UNYws1A1k8s/X5KXR8ghcq8qec6qAQqUUxYCeN4PTM dIxufJ9m/FkbUL5/0YitM7JKoAEIWwP+SK9FDZ9TomL39zZz43rkWDkpaCyCQJU+99tM 5VEK42pl4Nxhk6Zhsa8kkrUTQ7jtyZhwBG6FDBCZ5CGYElqMVqlRK+plgd0kliKaFr45 XqIA== X-Gm-Message-State: ACgBeo3B6N+IDaEhIm+CpuOrcWNzC74qxoUVAnIPdDXlF9lb1Qi8FtnB zoENa5waiucMNvjoWs5rII7gPx/yo7AhOJ3XjAg= X-Google-Smtp-Source: AA6agR5by3h6PAEs6TUMd8En5MEvJAtPPmS2SiiXdXLR1w+ZKEosGvFzsdNf8g4iQvjNF9qrt9v86GlZ7Nk/HSEk1uU= X-Received: by 2002:a65:6c0c:0:b0:41b:8696:d9d7 with SMTP id y12-20020a656c0c000000b0041b8696d9d7mr25224489pgu.16.1660181159131; Wed, 10 Aug 2022 18:25:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Wed, 10 Aug 2022 18:25:47 -0700 Message-ID: Subject: Re: Possible C++ method signature warning feature? To: Paul Koning Cc: GCC Development Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2022 01:26:06 -0000 On Wed, Aug 10, 2022 at 6:20 PM Paul Koning via Gcc wrote= : > > There's a C++ problem I keep running into, in a very large body of softwa= re with lots of subclassing. > > There's a base class that defines a set of interface methods, not all pur= e virtual (some define the default behavior). A number of subclasses overr= ide 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 su= bclass 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 differ= ent argument list that isn't used anywhere). Finding these things can be h= ard and time consuming. > > It would be helpful to have some way to mark a method as "this is suppose= d to be an override of a base class method", in other words "warn me if thi= s 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 __attribut= e__ magic? Would it be interesting? > > paul >