diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-07-27 05:43:18 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-07-27 05:43:18 +0200 |
commit | 4ebaa72dec35a989ac1b51062d113dca5583ecae (patch) | |
tree | 6cdcd701af9cc0d1c17073d1548c44c76489fcc8 /src/vhdl/translate/trans-chap3.adb | |
parent | cb4a3ec7fbccbaeb0f3e84a824932b5022a9a3a0 (diff) | |
download | ghdl-4ebaa72dec35a989ac1b51062d113dca5583ecae.tar.gz ghdl-4ebaa72dec35a989ac1b51062d113dca5583ecae.tar.bz2 ghdl-4ebaa72dec35a989ac1b51062d113dca5583ecae.zip |
Translation: consider big arrays as non-static.
Fix #392
Diffstat (limited to 'src/vhdl/translate/trans-chap3.adb')
-rw-r--r-- | src/vhdl/translate/trans-chap3.adb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index b1ebb3aa7..fc69bdc05 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -836,6 +836,7 @@ package body Trans.Chap3 is is Indexes_List : constant Iir_List := Get_Index_Subtype_List (Def); Index : Iir; + Idx_Len : Iir_Int64; Len : Iir_Int64; begin -- Check if the bounds of the array are locally static. @@ -847,7 +848,17 @@ package body Trans.Chap3 is if Get_Type_Staticness (Index) /= Locally then return -1; end if; - Len := Len * Eval_Discrete_Type_Length (Index); + Idx_Len := Eval_Discrete_Type_Length (Index); + + -- Do not consider very large arrays as static, to avoid overflow at + -- compile time. + if Idx_Len >= 2**31 then + return -1; + end if; + Len := Len * Idx_Len; + if Len >= 2**31 then + return -1; + end if; end loop; return Len; end Get_Array_Subtype_Length; |