Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-2512

wtperf: MSVC complains about float conversion in throttle code

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • WT2.9.0
    • Affects Version/s: None
    • Component/s: None
    • None

      david.hows, in wtperf/wtperf_throttle.c, there's this code:

      throttle_cfg->ops_count =
          (uint64_t) (float)(usecs_delta /
          throttle_cfg->usecs_increment) *
          (float)throttle_cfg->ops_per_increment;
      throttle_cfg->last_increment = now;
      

      and MSVC complains:

      bench\wtperf\wtperf_throttle.c(110): warning C4244: '=': conversion from
      'float' to 'uint64_t', possible loss of data
      

      I'm not sure what's going on here – all of the fields are uint64_t, not sure why we're casting everything to float, couldn't we get the same results using an integer expression?

      I suspect the warning would go away if we just cast the result of the calculation to uint64_t, but I don't really understand what's going on here.

            Assignee:
            david.hows David Hows
            Reporter:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: