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

compiler warning #2341

Closed
laoshaw opened this issue Aug 6, 2020 · 2 comments
Closed

compiler warning #2341

laoshaw opened this issue Aug 6, 2020 · 2 comments
Labels
state: please discuss please discuss the issue or vote for your favorite option state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated

Comments

@laoshaw
Copy link

laoshaw commented Aug 6, 2020

json.hpp:15411:15; warning: comparing floating-point with '==' or '!=' is unsafe[-Wsafe-equal]

if(value==0) //+-0

not sure if this is a really bug but if value is a float then it should not compare to 0 directly.

@nlohmann
Copy link
Owner

nlohmann commented Aug 6, 2020

No, in that setting I really want to check whether the value is exactly 0. I am not sure how to convince the compiler that I don't want to be warned there. We already do

// disable float-equal warnings on GCC/clang
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wfloat-equal"
#endif

Should I also suppress -Wsafe-equal?

@nlohmann nlohmann removed the kind: bug label Aug 6, 2020
@nlohmann nlohmann added the state: please discuss please discuss the issue or vote for your favorite option label Aug 13, 2020
@stale
Copy link

stale bot commented Sep 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Sep 12, 2020
@stale stale bot closed this as completed Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: please discuss please discuss the issue or vote for your favorite option state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated
Projects
None yet
Development

No branches or pull requests

2 participants