From dde98158b59f6686c95b7ef41a32b5093e0d0956 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Fri, 6 Nov 2020 13:35:47 -0500 Subject: [PATCH] test: ensure reliable floating point comparison Without `volatile`, the x87 hardware may re-organize the comparison math and end up with the wrong answer. Fixes: one bullet point item of https://github.com/libuv/libuv/issues/2655 and the tests from https://github.com/libuv/libuv/pull/849 in certain build configurations PR-URL: https://github.com/libuv/libuv/pull/2747 Reviewed-By: Colin Ihrig --- test/task.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/task.h b/test/task.h index 2145744b..4e7e2f07 100644 --- a/test/task.h +++ b/test/task.h @@ -113,8 +113,8 @@ typedef enum { #define ASSERT_BASE(a, operator, b, type, conv) \ do { \ - type eval_a = (type) (a); \ - type eval_b = (type) (b); \ + volatile type eval_a = (type) (a); \ + volatile type eval_b = (type) (b); \ if (!(eval_a operator eval_b)) { \ fprintf(stderr, \ "Assertion failed in %s on line %d: `%s %s %s` " \