This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Wconversion
- To: Patrik Hagglund <patha at softlab dot ericsson dot se>
- Subject: Re: -Wconversion
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Sun, 20 Aug 2000 00:30:52 -0700
- Cc: gcc at gcc dot gnu dot org
- References: <20000714172728.5234B583E@hunny.softlab.se> <20000714104122.G21403@wolery.cumb.org> <zack@wolery.cumb.org> <20000714182948.84A6A583E@hunny.softlab.se>
On Fri, Jul 14, 2000 at 08:29:49PM +0200, Patrik Hagglund wrote:
> > We don't put it in -Wtraditional because the warning triggers for
> > legitimate code and there's no way to get rid of it. For instance, it
> > will complain about every function in <math.h> that takes float rather
> > than double arguments (sinf, cosf, etc.) -Wconversion is not intended
> > for day-to-day use; -Wtraditional is.
>
> I thought -Wtraditional only was intended for code that is
> translated from traditional C to C89.
-Wtraditional is intended to warn you about things that will cause
trouble if you compile your code with a K+R compiler. It's quite
useful in the day-to-day.
That warning set probably should include the -Wconversion warnings,
come to think of it - a popular approach is to use clever macros to
elide the prototypes if __STDC__ is not defined, so if the prototype
doesn't match the default conversion, you are in trouble. We'd have
to turn it off in system headers - perhaps we should do that anyway...
> > The purpose of -Wconversion is to shake out bugs introduced when you
> > add prototypes to a program that did not have them.
>
> I still think this is confusing. -Wconversion seems to has more
> than one purpose. For example:
>
> Also, warn if a negative integer constant expression is implicitly
> converted to an unsigned type. For example, warn about the
> assignment `x = -1' if `x' is unsigned. But do not warn about
> explicit casts like `(unsigned) -1'.
Yeah. That is confusing. It should probably be triggered by -W,
which has the other warnings of that stripe.
Patches are welcome, as lwall says.
zw