From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DB0B13858421; Sat, 13 Nov 2021 10:08:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB0B13858421 From: "egallager at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66773] sign-compare warning for == and != are pretty useless Date: Sat, 13 Nov 2021 10:08:42 +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: 4.7.2 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: egallager at gcc dot gnu.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: cc 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Nov 2021 10:08:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66773 Eric Gallager changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.o= rg --- Comment #25 from Eric Gallager --- (In reply to Segher Boessenkool from comment #16) > (In reply to Eric Gallager from comment #13) > > > Yes. You should not use casts, except in some very specific cases, a= nd > > > most of the uses you see "in the wild" are a bad idea. Sometimes I > > > wonder if we should have a -Wcast ("Warn for any cast."). > >=20 > > I get the feeling that such a warning would be extremely noisy and that > > no one would use it. >=20 > It was not meant as a serious suggestion of course, or I would have done > this many many years ago. OK, but I still think some of the ideas I came up with in response to it are good ideas, though; I'd like to amend this comment #13 in response: > It would probably be better to go about improving existing cast-related > warnings, or adding new ones for specific cases, rather than breaking out > such a broad hammer. For example, the fixits that David Malcolm added for > -Wold-style-cast are very nice; extending those to apply to more > cast-related warnings would be a good improvement (I've been meaning to > open a separate bug about this). These would all be better, more-specific > warnings to add: > * -Wcast-to-the-same-type (bug 85043) > * -Wcast-variadic-function-type (bug 87379) > * -Wfunctional-cast (bug 69818) > * -Wcast-enum (bug 30357) > * -Wold-style-cast-qual (fixit would suggest using const_cast instead) > * -Wold-style-useless-cast > * Any of clang's cast-related warnings that we currently don't have yet; > grep https://clang.llvm.org/docs/DiagnosticsReference.html for the word > "cast" to find some To this list, I'd like to add: * -Wold-style-cast-align (similar to -Wold-style-cast-qual) * -Wuseless-old-style-cast (as an alternate spelling of -Wold-style-useless-cast)=