From: Ian Lance Taylor Date: Mon, 23 Apr 2012 20:49:33 +0000 (+0000) Subject: compiler: Correct handling of negative zero floating constant. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=073d123ccf7036f9b103cc73f1a9b1bc3dd90d3b;p=gcc.git compiler: Correct handling of negative zero floating constant. From-SVN: r186722 --- diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index cb94e4f8dd9..945f379465a 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -13620,7 +13620,13 @@ Numeric_constant::set_float(Type* type, const mpfr_t val) this->clear(); this->classification_ = NC_FLOAT; this->type_ = type; - mpfr_init_set(this->u_.float_val, val, GMP_RNDN); + // Numeric constants do not have negative zero values, so remove + // them here. They also don't have infinity or NaN values, but we + // should never see them here. + if (mpfr_zero_p(val)) + mpfr_init_set_ui(this->u_.float_val, 0, GMP_RNDN); + else + mpfr_init_set(this->u_.float_val, val, GMP_RNDN); } // Set to a complex value.