This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: implicit narrowing conversion.
- From: "Joseph S. Myers" <jsm at polyomino dot org dot uk>
- To: Adam Sulmicki <adam at cfar dot umd dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 23 Jun 2004 19:29:59 +0000 (UTC)
- Subject: Re: implicit narrowing conversion.
- References: <20040623144721.W63388-200000@www.missl.cs.umd.edu>
On Wed, 23 Jun 2004, Adam Sulmicki wrote:
> hmm that stuff is 4 years old. In that case how about the attached patch?
We can't consider patches that don't follow the instructions at
<http://gcc.gnu.org/contribute.html>, in particular documentation and
testcases. In this case, there's also the problem of disentangling the
useless warnings from the present -Wconversion: ones relevant for K&R code
just converted to C90, but useless for most code being maintained as C90.
Without those separated out, -Wconversion produces too much junk to be
useful on real code. But some of the existing -Wconversion warnings are
useful.
Writing first the documentation, then the testcases, then the
implementation, is a good discipline for this sort of thing. The
documentation is easy, as the specification of the new -Wconversion is
just "warn for any implicit conversion that may change a value" and
splitting that into separate options (apart from moving the current
warnings to -Wconversion-traditional) is something that can wait for a
separate patch. The testcases would probably be several hundred lines
(covering all types of implicit conversions and all ways they might change
a value, plus some for -Wconversion-traditional, and making sure that you
don't e.g. get warnings for converting constant 0 to unsigned int, or
unsigned short -> int -> unsigned int) - rather bigger than the code
changes.
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)