diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-06-09 08:49:06 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2012-06-09 08:49:06 +0000 |
commit | f3250c32ff42ae18fd03a5311c1f0caec3415aba (patch) | |
tree | b37da52bcf8015c4b29bb8387c30727e2b4de824 /cfrontend/Csem.v | |
parent | 326d33e5b0f9dc0d3ccf6d75c62fedbc3ca085e5 (diff) | |
download | compcert-f3250c32ff42ae18fd03a5311c1f0caec3415aba.tar.gz compcert-f3250c32ff42ae18fd03a5311c1f0caec3415aba.zip |
Make min_int / -1 and min_int % -1 semantically undefined
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1919 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend/Csem.v')
-rw-r--r-- | cfrontend/Csem.v | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cfrontend/Csem.v b/cfrontend/Csem.v index 9087aa4c..ac7a58f6 100644 --- a/cfrontend/Csem.v +++ b/cfrontend/Csem.v @@ -300,7 +300,9 @@ Function sem_div (v1:val) (t1:type) (v2: val) (t2:type) : option val := | div_case_ii Signed => match v1,v2 with | Vint n1, Vint n2 => - if Int.eq n2 Int.zero then None else Some (Vint(Int.divs n1 n2)) + if Int.eq n2 Int.zero + || Int.eq n1 (Int.repr Int.min_signed) && Int.eq n2 Int.mone + then None else Some (Vint(Int.divs n1 n2)) | _,_ => None end | div_case_ff => @@ -333,7 +335,9 @@ Function sem_mod (v1:val) (t1:type) (v2: val) (t2:type) : option val := | binint_case_ii Signed => match v1,v2 with | Vint n1, Vint n2 => - if Int.eq n2 Int.zero then None else Some (Vint (Int.mods n1 n2)) + if Int.eq n2 Int.zero + || Int.eq n1 (Int.repr Int.min_signed) && Int.eq n2 Int.mone + then None else Some (Vint (Int.mods n1 n2)) | _, _ => None end | binint_default => |