This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: Wcomparison-fixed (PR7651 Define -Wextra strictly in terms of other warning flags)


:ADDPATCH c/c++:

As part of the effort to fix PR7651 [1], I proposed a
Wfutile-unsigned-comparison option (enabled by -Wextra) to take over
the function of warning  about comparison of unsigned variables
against zero with < or >=. [2]  This little gem is particularly
disliked by (some?) kernel devs [3], so having an option to disable it
seems worthwhile.

Gabriel dos Reis replied that this switch should include an unnamed
warning for comparisons that are always true because of type range
limits. That warning has received its own ration of animosity from
users [4][5].

The new Wcomparison-fixed option comprises those warnings. (The name
was first proposed by Joseph Myers in a comment of PR12963 [4])

Yet, I am not able to come up with good and portable testcases for the
comparisons that are always true (or false) because of type range
limits. Can anyone suggest some testcases?

Thanks in advance,

Manuel.


[1] http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01103.html [2] http://gcc.gnu.org/ml/gcc-patches/2006-12/msg01661.html [3] http://kerneltrap.org/node/7434 [4] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963 [5] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11856

2007-01-10 Manuel Lopez-Ibanez <manu@gcc.gnu.org>

  PR c/12963
  PR c++/11856
  PR middle-end/7651
  * c.opt (Wcomparison-fixed): New.
  * doc/invoke.texi (Wcomparison-fixed): Document it.
  (Wextra): Enabled by -Wextra.
  * c-opts.c (c_common_post_options): Enabled by -Wextra.
  * c-common.c (shorten_compare): Unconditional warning enabled only
by Wcomparison-fixed. Replace Wextra with Wcomparison-fixed.

testsuite/
2007-01-10  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

  PR c/12963
  PR c++/11856
  PR middle-end/7651
  * gcc.dg/compare6.c: Replace Wall with Wcomparison-fixed.
  * gcc.dg/Wcomparison-fixed.c: New.
  * gcc.dg/Wcomparison-fixed-Wextra.c: New.
  * gcc.dg/Wcomparison-fixed-no.c: New.
  * g++.dg/warn/Wcomparison-fixed.C: New.
  * g++.dg/warn/Wcomparison-fixed-Wextra.C: New.
  * g++.dg/warn/Wcomparison-fixed-no.C: New.

Attachment: wcomparison-fixed.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]