let handle_signed_overflow ~with_alarms syntactic_context typ e interpreted_e =
  match unrollType typ with
    TInt(kind, _)
      when Value_parameters.SignedOverflow.get()
        && isSigned kind ->
          let size = bitsSizeOf typ in
          let mn, mx =
            let b = Int.power_two (size-1) in
            Int.neg b, Int.pred b
          in
          let mn64 = Int.to_int64 mn in
          let mx64 = Int.to_int64 mx in
          let warn_under, warn_over =
            try
              let i = V.project_ival interpreted_e in
              let imn, imx = Ival.min_and_max i in
              let u = 
                match imn with 
                  Some bound when Int.ge bound mn -> None
                | _ -> Some mn64
              in
              let o = 
                match imx with 
                  Some bound when Int.le bound mx -> None
                | _ -> Some mx64
              in
              u, o
            with V.Not_based_on_null ->
              Some mn64, Some mx64
          in
          let all_values =
            Cvalue_type.V.inject_ival (Ival.inject_range (Some mn) (Some mx))
          in
          if V.is_included interpreted_e all_values
          then interpreted_e
          else begin
              CilE.set_syntactic_context syntactic_context;
              CilE.warn_signed_overflow with_alarms e
                warn_under warn_over;
              let r = V.narrow all_values interpreted_e in
              Value_parameters.debug
                "signed overflow: %a reduced to %a@."
                V.pretty interpreted_e
                V.pretty r;
              r
            end
  | _ -> interpreted_e