Bug 38055 - key for compilation -Wconversion
Summary: key for compilation -Wconversion
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-07 19:24 UTC by Lisp2D
Modified: 2009-01-24 06:00 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lisp2D 2008-11-07 19:24:54 UTC
The key for compilation -Wconversion is very important.
 Its absence by default hides programming errors on different platforms.
 It is desirable to include this key with the help -Wall.
Comment 1 Manuel López-Ibáñez 2009-01-24 01:40:37 UTC
Quoting the FAQ at http://gcc.gnu.org/wiki/NewWconversion#faq

Why Wconversion is not enabled by -Wall or at least by -Wextra?

Implicit conversions are very common in C. This tied with the fact that there is no data-flow in front-ends (see next question) results in hard to avoid warnings for perfectly working and valid code. Wconversion is designed for a niche of uses (security audits, porting 32 bit code to 64 bit, etc.) where the programmer is willing to accept and workaround invalid warnings. Therefore, it shouldn't be enabled if it is not explicitly requested. 
Comment 2 Lisp2D 2009-01-24 06:00:07 UTC
The niche is selected incorrectly. Basically the considerable quantity of errors of programming is linked to implicit type conversion.

void insert(char*,char,unsigned int){..}

insert(..,..,size_t);

Example

double d = 1.0;
int i;
i = d;

correctly and necessary to write so:

double d = 1.0;
int i;
i = (int)d;

In the program text this obvious conversion will be visible.