aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/g-table.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-05-21 12:52:48 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-05-21 12:52:48 +0200
commit6413dd818096d3d76b6da424f454da7638bfe847 (patch)
treea4c5ef63a6f4bff40cee7c54bc04bbb6b0aaffc9 /gcc/ada/g-table.adb
parent2735b82d096137ab53517510fd3669e60a663915 (diff)
downloadgcc-6413dd818096d3d76b6da424f454da7638bfe847.zip
gcc-6413dd818096d3d76b6da424f454da7638bfe847.tar.gz
gcc-6413dd818096d3d76b6da424f454da7638bfe847.tar.bz2
[multiple changes]
2014-05-21 Bob Duff <duff@adacore.com> * sem_util.adb (Is_Dependent_Component_Of_Mutable_Object): This was returning False if the Object is a constant view. Fix it to return True in that case, because it might be a view of a variable. (Has_Discriminant_Dependent_Constraint): Fix latent bug; this function was crashing when passed a discriminant. 2014-05-21 Robert Dewar <dewar@adacore.com> * gnat_ugn.texi: Remove misplaced section that is now obsolete. * s-arit64.adb: Minor code reorganization. * sem_prag.adb: Minor comment fix (remove erroneous use of the term erroneous). 2014-05-21 Robert Dewar <dewar@adacore.com> * g-table.adb, g-dyntab.adb (Reallocate): Fix possible overflow in computing new table size. From-SVN: r210690
Diffstat (limited to 'gcc/ada/g-table.adb')
-rw-r--r--gcc/ada/g-table.adb24
1 files changed, 14 insertions, 10 deletions
diff --git a/gcc/ada/g-table.adb b/gcc/ada/g-table.adb
index 9b3692b..e12e84f 100644
--- a/gcc/ada/g-table.adb
+++ b/gcc/ada/g-table.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1998-2013, AdaCore --
+-- Copyright (C) 1998-2014, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -196,21 +196,25 @@ package body GNAT.Table is
----------------
procedure Reallocate is
- New_Size : size_t;
+ New_Size : size_t;
+ New_Length : Long_Long_Integer;
begin
if Max < Last_Val then
pragma Assert (not Locked);
- while Max < Last_Val loop
-
- -- Increase length using the table increment factor, but make
- -- sure that we add at least ten elements (this avoids a loop
- -- for silly small increment values)
+ -- Now increment table length until it is sufficiently large. Use
+ -- the increment value or 10, which ever is larger (the reason
+ -- for the use of 10 here is to ensure that the table does really
+ -- increase in size (which would not be the case for a table of
+ -- length 10 increased by 3% for instance). Do the intermediate
+ -- calculation in Long_Long_Integer to avoid overflow.
- Length := Integer'Max
- (Length * (100 + Table_Increment) / 100,
- Length + 10);
+ while Max < Last_Val loop
+ New_Length :=
+ Long_Long_Integer (Length) *
+ (100 + Long_Long_Integer (Table_Increment)) / 100;
+ Length := Integer'Max (Integer (New_Length), Length + 10);
Max := Min + Length - 1;
end loop;
end if;