diff options
author | Julien Bortolussi <bortolussi@adacore.com> | 2022-08-04 18:15:13 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2022-09-06 09:14:21 +0200 |
commit | eae9f5d25713013a6fa3e6c60f7f744ab3bf778b (patch) | |
tree | b075e3b68d6e89a1260a918977e6ec2f99981d0a /gcc/ada/libgnat | |
parent | c56c7d3aeb050ddfe7a41cc00ce5eaa5c4edd636 (diff) | |
download | gcc-eae9f5d25713013a6fa3e6c60f7f744ab3bf778b.zip gcc-eae9f5d25713013a6fa3e6c60f7f744ab3bf778b.tar.gz gcc-eae9f5d25713013a6fa3e6c60f7f744ab3bf778b.tar.bz2 |
[Ada] Fix a bug in the contract of formal ordered sets
There are 2 main issues in the postcondition of the function Replace
of the formal ordered sets, in the sub package Generic_Keys. One is
related to the fact that when the element is changed, the key is
also changed. The second one is due to the fact that the arrival of
the new element might modify the ordering of the set and thus
the Positions might be modified.
As a consequence, the postcondition might be false and thus fail
at runtime.
gcc/ada/
* libgnat/a-cforse.ads (Replace): Fix the postcondition.
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r-- | gcc/ada/libgnat/a-cforse.ads | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/ada/libgnat/a-cforse.ads b/gcc/ada/libgnat/a-cforse.ads index ff96d8e..f6cca0f 100644 --- a/gcc/ada/libgnat/a-cforse.ads +++ b/gcc/ada/libgnat/a-cforse.ads @@ -1598,7 +1598,7 @@ is -- Key now maps to New_Item - and Element (Container, Key) = New_Item + and Element (Container, Find (Container, Key)'Old) = New_Item -- New_Item is contained in Container @@ -1622,8 +1622,9 @@ is E_Right => Elements (Container), P_Left => Positions (Container)'Old, P_Right => Positions (Container), - Position => Find (Container, Key)) - and Positions (Container) = Positions (Container)'Old; + Position => Find (Container, Key)'Old) + and P.Keys_Included (Positions (Container), + Positions (Container)'Old); procedure Exclude (Container : in out Set; Key : Key_Type) with Global => null, |