This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils 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: [PATCH] Avoid signed/unsigned comparison


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.


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