Closed Bug 1577051 Opened 2 years ago Closed 2 years ago

FastBernoulliTrial.h has an implicit integer-to-float conversion that changes value, triggering a warning with new-enough clang

Categories

(Core :: MFBT, task)

task
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: Waldo, Assigned: Waldo)

Details

Attachments

(1 file)

clang tip has a compiler warning for implicit integer-to-float conversions that change value, and FastBernoulliTrial.h contains such a conversion (in code to truncate-and-clamp a double to size_t)

    double skipCount =
        std::floor(std::log(mGenerator.nextDouble()) * mInvLogNotProbability);
    if (skipCount < SIZE_MAX)
      mSkipCount = skipCount;
    else
      mSkipCount = SIZE_MAX;

in skipCount < SIZE_MAX when size_t on the right-hand side is converted to double.

Either value permissibly produced by that conversion is acceptable, so just do an explicit conversion to silence the warning.

Duplicate of this bug: 1577236
Pushed by jwalden@mit.edu:
https://hg.mozilla.org/integration/autoland/rev/d72f6bb552f3
Fix an implicit-conversion-changes-value warning with new-enough clang by explicitly converting.  r=froydnj
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.