let do_promotion ~with_alarms ~src_typ ~dest_type v e_src =
  match dest_type, src_typ with
  | TFloat _, TInt _ ->
      Cvalue.V.cast_int_to_float ~with_alarms (get_rounding_mode()) v
  | TInt (kind,_), TFloat _ ->
      let size = bitsSizeOf dest_type in
      let signed = isSigned kind in
      let alarm_use_as_float, alarm_overflow, r =
        Cvalue.V.cast_float_to_int ~signed ~size v
      in
      if alarm_use_as_float
      then begin
          warning_once_current
            "converting %a to float: assert(Ook)"
            !d_exp e_src;
        end;
      if alarm_overflow
      then
        warning_once_current
          "Overflow in cast of %a (%a) from floating-point to integer: assert(Ook)"
          !d_exp e_src
          Cvalue.V.pretty v;
      r
  | _, _ -> v