proposed patch for constant signed/unsigned comparison warning
Jim Wilson
wilson@cygnus.com
Thu Sep 25 01:14:00 GMT 1997
When rms originally installed this
warning, it wasn't enabled with -Wall; it was enabled by the ``extra
warning'' option -W. This seems reasonable to me, though it's even
more reasonable to separate it out into a separate -Wsign-compare
option, as is done with my proposed patch. The point, though, is that
this warning shouldn't be enabled by -Wall.
It was Jason Merrill who added the -Wsign-compare option and made -Wall enable
it. I asked him about this, and he said the purpose of this was only so that
the warnings could be turned off. Previously, they were enabled by -W, and
there was no way to get the other -W warnings without also getting the
comparison warning. -Wsign-compare was added so that the warnings could be
turned off. Of course, now that there was a new variable, it needed to be
set someplace, and he choose to have -Wall set it, but there was no particular
reason for this choice. Perhaps this was done because -Wall sets numerous
warn_* variables, but -W does not.
Since this particular change was not intentional, there does not seem to be
any reason why it must be retained. I think we could make everyone happy
here if we changed this back so that -Wsign-compare is enabled by -W.
This seems to match the intent of -W, and also makes it easy for people
to still get the warnings. And people can still disable the warning by
using -Wno-sign-compare.
I don't like the idea of only enabling the warning if -Wsign-compare is given.
The warning is very useful for some people, but they may never know they
need it if it is only enabled by some obscure option. If -W enables it,
then people will still get the warnings if they use -W.
Or maybe we need a -Weverything option, which includes all warnings, even
those that we don't want enabled by -Wall?
Jim
More information about the Gcc
mailing list