From c748293ccbe4edc6a9f789ca0bfd5790e8d9e52b Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Fri, 23 Nov 2012 06:41:06 +0000 Subject: [PATCH] Use memcmp for comparing doubles --- parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser.c b/parser.c index d61a416..fd4e859 100644 --- a/parser.c +++ b/parser.c @@ -167,7 +167,8 @@ static ast_value* parser_const_float(parser_t *parser, double d) size_t i; ast_value *out; for (i = 0; i < vec_size(parser->imm_float); ++i) { - if ((double)(parser->imm_float[i]->constval.vfloat) == d) + const double compare = parser->imm_float[i]->constval.vfloat; + if (memcmp((const void*)&compare, (const void *)&d, sizeof(double)) == 0) return parser->imm_float[i]; } out = ast_value_new(parser_ctx(parser), "#IMMEDIATE", TYPE_FLOAT); -- 2.39.2