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

[C++] Make code compile with -Wfloat-equal #8221

Merged
merged 2 commits into from
May 29, 2024

Conversation

fliiiix
Copy link
Contributor

@fliiiix fliiiix commented Jan 21, 2024

This will allow the code to be compiled with -Wfloat-equal as this would result in the folowing warning/error: vendor/flatbuffers/include/flatbuffers/base.h:465:69:
error: comparing floating point with == or != is unsafe [-Werror,-Wfloat-equal]
template inline bool IsTheSameAs(T e, T def) { return e == def; }

But the way it is used in flatbuffers it is ok to compare floating points with ==.

@github-actions github-actions bot added the c++ label Jan 21, 2024
This will allow the code to be compiled with `-Wfloat-equal`
as this would result in the folowing warning/error:
vendor/flatbuffers/include/flatbuffers/base.h:465:69:
  error: comparing floating point with == or != is unsafe [-Werror,-Wfloat-equal]
template<typename T> inline bool IsTheSameAs(T e, T def) { return e == def; }

But the way it is used in flatbuffers it is ok to compare floating
points with ==.
@dbaileychess dbaileychess enabled auto-merge (squash) May 29, 2024 02:49
@dbaileychess dbaileychess merged commit 0e034ec into google:master May 29, 2024
45 checks passed
@fliiiix fliiiix deleted the bugfix/float-compare branch June 1, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants