Re: char y = 469;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



stf_polska wrote:
> Hello
>
> How to get a warning for this:
>
>     int x = 469;
>     char y = x;
>
> (some bits are being cut off on my machine)
>
> using gcc or g++?
>
It's not a language violation, nor could ever be one.  So why would the
compiler warn about it? 

Also there are many instances where you would assign an int to a char. 
For example, the tolower(), toupper(), etc macros. 

If you want these sorts of warnings use a lint tool like splint .   But
better yet is to use data types you require and not just ones you pick
willy-nilly.


Tom

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux