This is the mail archive of the gcc-help@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]
Other format: [Raw text]

Re: Switch to obtain "narrowing" warnings


> Excuse my newbieness, but is there a gcc switch that enables warnings
> from implicit narrowing (int -> short, for example), or is this best
> obtained from other software such as lint/splint?


-Wconversion does this, in newer versions of gcc.

Interesting. It could well be my mistake, but shouldn't "gcc
-Wconversion test.c" throw at least some unhappiness with:

#include <stdio.h>
int main(void){
 int i=99999;
 short s;
 s=i;
 printf("s is %d\n", s);
 return 0;
}

It does just that, with *newer* versions of GCC -- 4.2.0 doesn't yet do this, you need an unreleased version right now.


Segher



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