We have a loop with the following termination code in uintp.num_bits
This sure looks like a bug in Num_Bits to me, not in the compilation
of the front-end.
The relevant code is:
function Num_Bits (Input : Uint) return Nat is
Bits : Nat;
Num : Nat;
begin
if UI_Is_In_Int_Range (Input) then
Num := abs (UI_To_Int (Input));
Bits := 0;
This code only works for one-complement machines, since it assumes a
symmetric range for Int. It breaks when UI_To_Int returns Integer'First, as
it did in this case. When it does, the abs produces an erroneous result
(since checking is disabled). So it almost doesn't matter what it puts into
Num (but it actually puts in an out-of-range value there too).
Robert, what's the proper fix here?