From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5609 invoked by alias); 29 Dec 2002 12:06:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 5595 invoked by uid 71); 29 Dec 2002 12:06:01 -0000 Date: Sun, 29 Dec 2002 04:06:00 -0000 Message-ID: <20021229120601.5594.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Joseph S. Myers" Subject: Re: c/9072: -Wconversion should be split into two distinct flags Reply-To: "Joseph S. Myers" X-SW-Source: 2002-12/txt/msg01363.txt.bz2 List-Id: The following reply was made to PR c/9072; it has been noted by GNATS. From: "Joseph S. Myers" To: Zack Weinberg Cc: Segher Boessenkool , <128950@bugs.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