Re: implicit cast from unsigned long to unsigned int gives no warning with -Wall (64 bits arch)

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

 



Vincent Torri writes:
 > 
 > hey,
 > 
 > I have an ubuntu 64 bits on my core 2 duo. gcc version is 4.1.2
 > 
 > I compile that code with -Wall:
 > 
 > 
 > 
 > unsigned int htonl (unsigned int i)
 > {
 >    i = 0;
 >    return 0;
 > }
 > 
 > int
 > main ()
 > {
 >    unsigned long i;
 >    unsigned int j;
 > 
 >    i = 0;
 >    j = htonl (i);
 > 
 >    return 0;
 > }
 > 
 > 
 > but no warning is given
 > 
 > Is it normal ?

Yes.  If we warned about every implict narrowing conversion 99% of C
code would generate warnings.

For example:

  short j;
  short i = 2 + j;

... etc.

Andrew.

-- 
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

[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