Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings for -Wimplicit-int-float-conversion #1373

Merged

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented Mar 30, 2024

longやunsigned longの変数をdoubleに暗黙的に変換している箇所は精度が失う可能性があるとclangに指摘されたため明示的にキャストstatic_cast<double>()を使いコンパイラに意図した変更であると伝えます。

clang 17のレポート (file pathを一部省略)

src/article/drawareabase.cpp:5452:46: warning: implicit conversion from 'gint64' (aka 'long') to 'double' may lose precision [-Wimplicit-int-float-conversion]
 5452 |     m_deceleration.elapsed += ( current_time - m_deceleration.last_time ) * kDecelerationRatio;
      |                                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~   ~
src/image/imageadmin.cpp:850:44: warning: implicit conversion from 'size_type' (aka 'unsigned long') to 'double' may lose precision [-Wimplicit-int-float-conversion]
  850 |         double upper =  m_list_view.size() * ICON_SIZE;
      |                ~~~~~    ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~

longやunsigned longの変数をdoubleに暗黙的に変換している箇所は
精度が失う可能性があるとclangに指摘されたため明示的にキャスト
`static_cast<double>()`を使いコンパイラに意図した変更であると伝えます。

clang 17のレポート (file pathを一部省略)
```
src/article/drawareabase.cpp:5452:46: warning: implicit conversion from 'gint64' (aka 'long') to 'double' may lose precision [-Wimplicit-int-float-conversion]
 5452 |     m_deceleration.elapsed += ( current_time - m_deceleration.last_time ) * kDecelerationRatio;
      |                                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~   ~
src/image/imageadmin.cpp:850:44: warning: implicit conversion from 'size_type' (aka 'unsigned long') to 'double' may lose precision [-Wimplicit-int-float-conversion]
  850 |         double upper =  m_list_view.size() * ICON_SIZE;
      |                ~~~~~    ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
```
@ma8ma ma8ma added the bug バグの追跡 label Mar 30, 2024
@ma8ma ma8ma merged commit 3e9c8d5 into master Mar 30, 2024
20 checks passed
@ma8ma ma8ma deleted the fix-compiler-warnings-for-Wimplicit-int-float-conversion branch March 30, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug バグの追跡
Projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant