Compiler warning fixes#870
Conversation
a573a5c to
d68fd26
Compare
d68fd26 to
64f0afb
Compare
64f0afb to
93aae68
Compare
93aae68 to
c1bae9f
Compare
-removed superfluous semicolon - added static_cast where it will definitely casue no change in behaviour - small adaptions in member and parameter types
c1bae9f to
5bd8fea
Compare
|
|
||
| inline bool operator==(const rvalue& l, double r) | ||
| inline bool operator==(const rvalue& l, const int& r) | ||
| { | ||
| return l.d() == r; | ||
| return l.i() == r; | ||
| } | ||
|
|
||
| inline bool operator==(double l, const rvalue& r) | ||
| inline bool operator==(const int& l, const rvalue& r) | ||
| { | ||
| return l == r.d(); | ||
| return l == r.i(); | ||
| } | ||
|
|
||
| inline bool operator!=(const rvalue& l, double r) | ||
| inline bool operator!=(const rvalue& l, const int& r) | ||
| { | ||
| return l.d() != r; | ||
| return l.i() != r; | ||
| } | ||
|
|
||
| inline bool operator!=(double l, const rvalue& r) | ||
| inline bool operator!=(const int& l, const rvalue& r) | ||
| { | ||
| return l != r.d(); | ||
| return l != r.i(); | ||
| } |
There was a problem hiding this comment.
This is not a compiler warning fix, this is a breaking change of the interface.
Before that change it was possible to compare a rvalue with an double, now it is impossible (it still is possible, but it doesn't do what you expect. Even worse).
And passing a int by const ref also seems... interesting
There was a problem hiding this comment.
Even worse:
auto data = crow::json::load(R"-({
"double": 4.5,
})-");
REQUIRE(data["double"] != 4.7);Does fail since 4.5 == 4.7 is true
There was a problem hiding this comment.
This is not a compiler warning fix, this is a breaking change of the interface. Before that change it was possible to compare a
rvaluewith an double, now it is impossible (it still is possible, but it doesn't do what you expect. Even worse). And passing a int by const ref also seems... interesting
Direct float comparisons are unsafe, look for the fitting compiler warning. Removal of float comparisons was intentional.
If you want to use it, use the accessor for its floating point value and do it.
There was a problem hiding this comment.
If it was intentional, please also remove comparison with integers. Otherwise you get unexpected results when comparing with double values.
Also, comparing double is absolutely fine (also see https://stackoverflow.com/a/11422298/10162645).
Also see my example. If i expect a specific floating value in my json I don't want a comparison with some epsilon, I want to check for strict equality.
No description provided.