This is the mail archive of the gcc-prs@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]

Re: c/9072: -Wconversion should be split into two distinct flags


The following reply was made to PR c/9072; it has been noted by GNATS.

From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: Zack Weinberg <zack@codesourcery.com>
Cc: Segher Boessenkool <segher@koffie.nl>,  <128950@bugs.debian.org>, 
     <gcc-patches@gcc.gnu.org>,  <gcc-gnats@gcc.gnu.org>, 
     <debian-gcc@lists.debian.org>
Subject: Re: c/9072: -Wconversion should be split into two distinct flags
Date: Sun, 29 Dec 2002 11:59:26 +0000 (GMT)

 On Sun, 29 Dec 2002, Zack Weinberg wrote:
 
 > I'm very much in favor of making -Wconversion more useful, but is
 > there any reason not to shift the argument-type-conversion warnings
 > entirely over to -Wtraditional?  Particularly if the warning is
 > avoided for prototypes in system headers (so that 'sinf' and the like
 > raise no complaints) -- this would, for instance, catch the occasional
 > problem we have with arguments of type 'bool' in GCC itself.
 > 
 > Then -Wconversion would be entirely for dubious type conversions on
 > assignment.
 
 I believe -Wconversion should have exactly the following simple
 specification: warn for any implicit conversion that may change a value.  
 This implies -Wsign-compare, parts of the existing -Wconversion (but not
 those for widening through prototype, etc.), and various cases that there
 isn't currently a warning option for (e.g. assigning a signed int to an
 unsigned int), and would be useful for security auditing.  The same
 intelligence used by -Wsign-compare to avoid warning where problems cannot
 in fact arise (e.g. comparing a constant positive signed integer to an
 unsigned integer) should be used.  Depending on how many warnings this
 generates for reasonable code, there may need to be options to disable
 individual parts (beyond the existing -Wno-sign-compare).
 
 Some parts of this might also be useful in -Wtraditional.
 
 Such a -Wconversion implementation would need thorough testcases (probably
 a few hundred lines, likely rather longer than the rest of the patch) for
 all the different cases of implicit conversion that do warn, or don't warn
 because that type conversion can't change values, or don't warn because
 that conversion is converting a constant (etc.) to the same value.
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 


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