This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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: [msp430-elf] Compile-time warnings


Hi Orlando,

Thanks for reporting these problems.  I would prioritize them as follows:


newlib/libc/stdlib/arc4random.c:102:17: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  rs->rs_count = 1600000;

Annoying rather than serious I would say.  The reset count will still 
receive a non-zero value, just not as large as the programmer had intended.
Still they obviously had not thought about 16-bit targets.  Worth fixing
one day, but not a priority.


newlib/libc/stdlib/nano-mallocr.c:222:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     align_p = (char*)ALIGN_TO((unsigned long)p, CHUNK_ALIGN);

I think that this one (and the others in nano-mallocr) is not actually
serious, in that the integer being used is larger than an a pointer, but
it does smack of sloppy programming.  Ideally a union ought to be used
to convert between the pointer and integer types.


newlib/libc/search/hash.h:146:22: warning: overflow in implicit constant conversion [-Woverflow]
 #define DEF_BUFSIZE  65536  /* 64 K */

More sloppy programming - assumption of a 32-bit int type.  This one might
actually be serious as it looks like it could impare the operation of the
hash functions in the newlib library.


newlib/libm/math/e_scalb.c:50:37: warning: overflow in implicit constant conversion [-Woverflow]
  if (-fn > 65000.0) return scalbn(x,-65000);
 
Another assumption of a 32-bit int.  Easily fixed by using scalbln instead 
of scalbn.


newlib/libm/common/s_round.c:71:26: warning: left shift count >= width of type [-Wshift-count-overflow]
             msw |= (1023 << 20);

Another one that should be fixed quickly.  Correct operation of the math
library is important to many programs.



If you do develop a patch or two to fix these issues, that would be most welcome.

Cheers
  Nick


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