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

Re: -Wconversion


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

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