From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 38E053858439; Thu, 4 May 2023 17:45:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38E053858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683222330; bh=ux7AoVSNzQMi2ooVO3h5ozrJjXDOZos+xNnzWFlyAQM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XDyAhxfkFevSLvUxRFCvpZOW05TK0SPXcgWvWmN6G3VSEba2j2U4WeOASCFNj5TS+ dWhwqF1c3mq6ADaEmDGST+OXqlE9OSxfseeuZ4cq5uJ+6jjGpUAkZAsiRo1x/+ns+c 5TIhkSm29YGTy4Mb7wuTMhovr8j2fxynyx5vKFik= From: "psmith at gnu dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109740] -Woverloaded-virtual is too aggressive Date: Thu, 04 May 2023 17:45:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: psmith at gnu dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109740 --- Comment #2 from Paul Smith --- What I'm trying to say is that it's not useful (to me) for GCC to warn about code that I could maybe write in the future but didn't actually write, and which if I did write it would generate a compiler error anyway, rather than "doing the wrong thing". On the other hand, it's very useful for GCC to warn me about situations whe= re I could be actually getting an unexpected result, without a compiler error. = For example if the parent method takes an int and the child method takes a char, then I might call B.foo(10) expecting to get the parent method but actually= the child method will be invoked. That kind of warning is very helpful. So, it would be nice to have a way to warn about things that might miscompi= le silently in unexpected ways, without also warning about things that can't possibly miscompile in unexpected ways. I did read the description in the docs, and the suggestion of adding using A::foo to the child class, but that inherits all the parent class's virtual methods into the child class which I don't want to do in all cases.=