This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [gold commit] PR 19577: Fix build failure in gold due to signed vs. unsigned comparisons


Cary Coutant <ccoutant@gmail.com> writes:

> diff --git a/gold/reloc.h b/gold/reloc.h
> index 4f1e753..fce7313 100644
> --- a/gold/reloc.h
> +++ b/gold/reloc.h
> @@ -1015,7 +1015,7 @@ class Bits
>      gold_assert(bits > 0 && bits <= 32);
>      if (bits == 32)
>        return false;
> -    int32_t max = static_cast<int32_t>((1U << bits) - 1);
> +    uint32_t max = static_cast<int32_t>((1U << bits) - 1);

Shouldn't the cast be changed as well?

>      return val > max;
>    }
>
> @@ -1081,7 +1081,7 @@ class Bits
>      gold_assert(bits > 0 && bits <= 64);
>      if (bits == 64)
>        return false;
> -    int64_t max = static_cast<int64_t>((static_cast<uint64_t>(1) << bits) - 1);
> +    uint64_t max = static_cast<int64_t>((static_cast<uint64_t>(1) <<
> bits) - 1);

Here the cast doesn't make sense any more.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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