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

[4.3] wcoercion (3): conversion_warnings for C / C++

Patch from the Wcoercion Project

This patch adds most of the new functionality of Wconversion: warn for implicit
conversions that may alter a value. This includes conversions between
real and integer, like abs (x) when x is double; conversions between
signed and unsigned, like unsigned ui = -1; and conversions to smaller
types, like sqrtf (M_PI). Do not warn for explicit casts like abs
((int) x) and ui = (unsigned) -1, or if the value is not changed by
the conversion like abs (2.0).

Note1: testcases are not added to c++ in this patch because: (1) there
is already a partial implementation of this in c++ with its own
testcases (2) the partial implementation warns for abs(2.0),
conflicting with my own implementation. The next patch will address
these issues.

Bootstrapped and tested with --enable-languages=all for trunk revision
1118055 on i686-pc-linux-gnu

:ADDPATCH c/c++:

2006-11-05 Manuel Lopez-Ibanez <>

      * c-common.c (conversion_warning): New.
      (convert_and_check): Call conversion_warning unless there is an
overflow warning.
      * doc/invoke.texi (-Wconversion): Update description.

2006-11-05  Manuel Lopez-Ibanez <>

      * gcc.dg/Wconversion-integer.c: New. Supersedes
      * gcc.dg/Wconversion-real.c: New.
      * gcc.dg/Wconversion-real-integer.c: New.
      * gcc.dg/Wconversion-negative-constants.c: Deleted.
      * g++.dg/warn/Wconversion1.C: Modified.

Attachment: wcoercion-3of3-coercion_warning.patch
Description: Binary data

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