summaryrefslogtreecommitdiff
path: root/lib/Support/JSON.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-02-05 18:38:58 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-02-05 18:38:58 +0000
commite79719ce607b6130e41e23dbdc90cc6b4e0401e6 (patch)
tree47bb93fafd9582425ebb778ec77002c222f64ed4 /lib/Support/JSON.cpp
parent3edec5c15a78e4abba7eb9102fef3891c84ebdfb (diff)
Diffstat (limited to 'lib/Support/JSON.cpp')
-rw-r--r--lib/Support/JSON.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Support/JSON.cpp b/lib/Support/JSON.cpp
index d468013fb94a5..07a556814915d 100644
--- a/lib/Support/JSON.cpp
+++ b/lib/Support/JSON.cpp
@@ -182,6 +182,12 @@ bool operator==(const Value &L, const Value &R) {
case Value::Boolean:
return *L.getAsBoolean() == *R.getAsBoolean();
case Value::Number:
+ // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
+ // The same integer must convert to the same double, per the standard.
+ // However we see 64-vs-80-bit precision comparisons with gcc-7 -O3 -m32.
+ // So we avoid floating point promotion for exact comparisons.
+ if (L.Type == Value::T_Integer || R.Type == Value::T_Integer)
+ return L.getAsInteger() == R.getAsInteger();
return *L.getAsNumber() == *R.getAsNumber();
case Value::String:
return *L.getAsString() == *R.getAsString();