diff options
Diffstat (limited to 'gcc/ada/table.adb')
-rw-r--r-- | gcc/ada/table.adb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/ada/table.adb b/gcc/ada/table.adb index 3bf4eb69c87..e6367af45a2 100644 --- a/gcc/ada/table.adb +++ b/gcc/ada/table.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- 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- -- @@ -172,6 +172,7 @@ package body Table is procedure Reallocate is New_Size : Memory.size_t; + New_Length : Long_Long_Integer; begin if Max < Last_Val then @@ -186,11 +187,14 @@ package body Table is -- 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). + -- length 10 increased by 3% for instance). Do the intermediate + -- calculation in Long_Long_Integer to avoid overflow. while Max < Last_Val loop - Length := Int'Max (Length * (100 + Table_Increment) / 100, - Length + 10); + New_Length := + Long_Long_Integer (Length) * + (100 + Long_Long_Integer (Table_Increment)) / 100; + Length := Int'Max (Int (New_Length), Length + 10); Max := Min + Length - 1; end loop; |