https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66773
Eric Gallager <egallager at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.org --- Comment #25 from Eric Gallager <egallager at gcc dot gnu.org> --- (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, and > > > 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."). > > > > I get the feeling that such a warning would be extremely noisy and that > > no one would use it. > > 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)