Bug 204834 - Clang 10 reports -Wimplicit-int-float-conversion compilation warnings
Summary: Clang 10 reports -Wimplicit-int-float-conversion compilation warnings
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords:
Depends on: 209955 210038 224714
Blocks:
  Show dependency treegraph
 
Reported: 2019-12-03 20:13 PST by Fujii Hironori
Modified: 2021-04-17 13:36 PDT (History)
23 users (show)

See Also:


Attachments
WIP patch (740 bytes, patch)
2019-12-03 20:35 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (11.27 KB, patch)
2020-04-01 15:45 PDT, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2019-12-03 20:13:38 PST
Clang 10 reports a compilation warning:

> wtf/MathExtras.h(401,43): warning: implicit conversion from 'unsigned long long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-int-float-conversion]
>         double fmodValue = fmod(trunc(d), std::numeric_limits<unsigned long long>::max() + 1.0);

doubleToInteger was added in Bug 67980.
Comment 1 Fujii Hironori 2019-12-03 20:25:39 PST
More warnings: 

> [20/129] Building CXX object Source\WTF\wtf\CMakeFiles\WTF.dir\MediaTime.cpp.obj
> ..\..\Source\WTF\wtf\MediaTime.cpp(117,21): warning: implicit conversion from 'long long' to 'float' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
>     if (floatTime > std::numeric_limits<int64_t>::max())
>                   ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ..\..\Source\WTF\wtf\MediaTime.cpp(124,36): warning: implicit conversion from 'long long' to 'float' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
>     while (floatTime * timeScale > std::numeric_limits<int64_t>::max())
>                                  ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ..\..\Source\WTF\wtf\MediaTime.cpp(147,22): warning: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
>     if (doubleTime > std::numeric_limits<int64_t>::max())
>                    ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ..\..\Source\WTF\wtf\MediaTime.cpp(154,37): warning: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-int-float-conversion]
>     while (doubleTime * timeScale > std::numeric_limits<int64_t>::max())
>                                   ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 4 warnings generated.
Comment 2 Fujii Hironori 2019-12-03 20:35:54 PST
Created attachment 384784 [details]
WIP patch
Comment 3 Fujii Hironori 2019-12-03 21:05:12 PST
Umm, there are more. Here is full compilation log after applying the WIP patch.
https://gist.github.com/fujii/160ae6e66138d6b48dc4e342f58837b6
Comment 4 Don Olmstead 2020-03-26 10:31:35 PDT
https://bugzilla.mozilla.org/show_bug.cgi?id=1577236

Here's Mozilla's work to fix this warning in their codebase
Comment 5 Fujii Hironori 2020-04-01 15:45:30 PDT
Created attachment 395215 [details]
Patch
Comment 6 Darin Adler 2020-04-01 16:26:12 PDT
Comment on attachment 395215 [details]
Patch

We don’t use typically function style casts in WebKit. We should look for other ways to do the conversion.

These warnings suggest there are mistakes in some of these places. I am not sure that just quieting the warning without a behavior change is good.
Comment 7 Fujii Hironori 2020-04-01 22:53:30 PDT
https://stackoverflow.com/a/17822304

This is interesting.
They uses an idea using ldexp which is similar approach with my WIP patch (comment 2).
Comment 8 Fujii Hironori 2020-04-03 01:23:34 PDT
Filed: Bug 209955 – [Clang 10] Fix -Wimplicit-int-float-conversion compilation warnings in WTF