[Ada] Fix problematic underflow for Float_Type'Value
We need a couple of guards for boundary conditions in the support code. gcc/ada/ * libgnat/s-dourea.adb ("/"): Add guard for zero and infinite divisor. * libgnat/s-valuer.adb (Scan_Raw_Real): Add guard for very large exponent values.
This commit is contained in:
parent
ba89624e93
commit
7c77ec1199
@ -178,6 +178,12 @@ package body System.Double_Real is
|
||||
P, R : Double_T;
|
||||
|
||||
begin
|
||||
if Is_Infinity (B) or else Is_Zero (B) then
|
||||
return (A.Hi / B, 0.0);
|
||||
end if;
|
||||
pragma Annotate (CodePeer, Intentional, "test always false",
|
||||
"code deals with infinity");
|
||||
|
||||
Q1 := A.Hi / B;
|
||||
|
||||
-- Compute R = A - B * Q1
|
||||
@ -196,6 +202,12 @@ package body System.Double_Real is
|
||||
R, S : Double_T;
|
||||
|
||||
begin
|
||||
if Is_Infinity (B.Hi) or else Is_Zero (B.Hi) then
|
||||
return (A.Hi / B.Hi, 0.0);
|
||||
end if;
|
||||
pragma Annotate (CodePeer, Intentional, "test always false",
|
||||
"code deals with infinity");
|
||||
|
||||
Q1 := A.Hi / B.Hi;
|
||||
R := A - B * Q1;
|
||||
|
||||
|
@ -645,7 +645,14 @@ package body System.Value_R is
|
||||
|
||||
Ptr.all := Index;
|
||||
Scan_Exponent (Str, Ptr, Max, Expon, Real => True);
|
||||
Scale := Scale + Expon;
|
||||
|
||||
-- Handle very large exponents like Scan_Exponent
|
||||
|
||||
if Expon < Integer'First / 10 or else Expon > Integer'Last / 10 then
|
||||
Scale := Expon;
|
||||
else
|
||||
Scale := Scale + Expon;
|
||||
end if;
|
||||
|
||||
-- Here is where we check for a bad based number
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user