[PATCH] Avoid signed/unsigned comparison

Josh Stone jistone@redhat.com
Fri Apr 28 10:35:00 GMT 2017

On 04/27/2017 11:24 AM, Mark Wielaard wrote:
> On Thu, Apr 20, 2017 at 04:40:30PM +0200, Ulf Hermann wrote:
>> Some compilers implicitly cast the result of uint_fast16_t *
>> uint_fast16_t to something signed and then complain about the
>> comparison to (unsigned) size_t.
> Really? That is allowed? Using a signed type for uint_fast16_t?

I think integer promotion (which happens before the operation) may use a
signed int.  It has to preserve the sign of the value itself, but I
think not necessarily the signedness of the resulting type.

Glibc uses "unsigned int"/"unsigned long int" for uint_fast16_t on
32/64-bit platforms, which means you won't get integer promotion.

More information about the Elfutils-devel mailing list