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

clang -Wimplicit-int-float-conversion fixes #38886

Merged

Conversation

kevingranade
Copy link
Member

Summary

SUMMARY: None

Purpose of change

Fixes #36510
Fixes #37006
Clang 10 adds a new warning, this corrects our code or silences the warning when "we know better":tm:

Describe the solution

Replace INT_MAX with FLT_MAX in a number of places.
Silence the warning due to the hackery in fastexp().

Describe alternatives you've considered

Could silence more of the warnings, but FLT_MAX seems to be correct in all of those cases.
Could use std::numeric_limits::max() instead, but that's kind of just bikeshedding.

Additional Context

This replaces #38881 since something about github permissions prevents me from applying a fix to that one.

src/lightmap.cpp Outdated Show resolved Hide resolved
src/lightmap.cpp Outdated Show resolved Hide resolved
@ZhilkinSerg ZhilkinSerg added the [C++] Changes (can be) made in C++. Previously named `Code` label Mar 19, 2020
src/monmove.cpp Outdated Show resolved Hide resolved
src/npcmove.cpp Outdated Show resolved Hide resolved
src/options.cpp Outdated Show resolved Hide resolved
@@ -1237,8 +1237,12 @@ float fastexp( float x )
float f;
int i;
} u, v;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the same thing as I did in #38431?

#pragma GCC diagnostic ignored "-Wunknown-pragmas"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this one means "STFU about any warnings related to pragmas".
GCC was choking on the other ignored pragma because it didn't recognize the warning flag.

@ZhilkinSerg ZhilkinSerg merged commit f7bfc38 into CleverRaven:master Mar 19, 2020
@kevingranade kevingranade deleted the fix-clang10-int-float-warning branch June 28, 2020 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clang 10 -Wimplicit-int-float-conversion warnings clang 10 compile issue
3 participants