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 <cjihrig@gmail.com>
This commit is contained in:
parent
8d5af5e70e
commit
dde98158b5
@ -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` " \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user