Small patch to handle -Wfloat-equal warnings

https://groups.google.com/d/msg/protobuf/H8_D1hfg3p4/A2oPHdfUAgAJ
pull/6034/head
senhalil 6 years ago committed by Adam Cozzette
parent 27228494c3
commit 97e7ddc015
  1. 4
      src/google/protobuf/compiler/cpp/cpp_message.cc

@ -177,6 +177,10 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer,
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
// Message fields still have has_$name$() methods.
format("if ($prefix$has_$name$()) {\n");
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE
|| field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) {
// Handle float comparison to prevent -Wfloat-equal warnings
format("if (!($prefix$$name$() <= 0 && $prefix$$name$() >= 0)) {\n");
} else {
format("if ($prefix$$name$() != 0) {\n");
}

Loading…
Cancel
Save