Bug #55729 Enable -Wconversion in maintainer mode on gcc > 4.3
Submitted: 4 Aug 2010 6:46 Modified: 4 Aug 2010 6:49
Reporter: Vladislav Vaintroub Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any
Triage: Triaged: D3 (Medium)

[4 Aug 2010 6:46] Vladislav Vaintroub
MySQL code is full of implicit type conversion, and gcc normally does not warn about it (but other compilers do).

For example ,there is a lot of cases where size_t is converted to int, losing possibly valueable bits.

Likely,  -Wconversion might be first used together with -Wno-sign-conversion, because -Wconversion alone would bring too many warnings.

Also, -Wconversion in GCC < 4.3 does not make much sense, since it was used for something else (and meant conversion warnings from K&R to ANSI). the pre 4.3 -Wconversion is also too verbose, and often just generated wrong warnings.

Also, when fixing it it could make some sense to remove long and ulong datatypes where applicable (since those types are least portable, implicit conversion to and from longs typically results to warnings on Windows)

How to repeat:
compile mysql-next-mr-bugfixing with gcc >=4.3
like this

cmake . -DCMAKE_C_FLAGS="-Wconversion -Wno-sign-conversion" 
 -DCMAKE_CXX_FLAGS=="-Wconversion -Wno-sign-conversion"

Observe a lot of warnings, like..
"conversion to 'unsigned int' from 'size_t' may alter its value"
[4 Aug 2010 7:01] Vladislav Vaintroub
The "new" -Wconversion is described here http://gcc.gnu.org/wiki/NewWconversion.

Note, that switching this option on makes it more possible for Linux developer to prevent regressions with his pushes on Windows (since most common  Windows warnings are about type conversions losing bits)