From 61ddd976fe46723e1a367f6658d2872b6908a765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Fri, 24 Apr 2026 15:36:37 +0300 Subject: [PATCH] Revert "test: crt-test: Skip a test for cos(-NAN) == -NAN when optimizing" This reverts commit 1d8c107d49ec09ff7a953e4cbcaa0c5137b9367d. After 49e14021bee3a970cf29ed326c0b2fe0fc3dfb95, when using F(-NAN) instead of -F(NAN) to hide the negation, this test passes correctly. I hadn't realized that GCC and Clang optimized cos(-x) = cos(x), when I made 1d8c107d49ec09ff7a953e4cbcaa0c5137b9367d (and at the time, the F() macro didn't work properly with -NAN on all toolchains). --- test/crt-test.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/crt-test.c b/test/crt-test.c index 278d062..c3a6732 100644 --- a/test/crt-test.c +++ b/test/crt-test.c @@ -1476,19 +1476,13 @@ void test_math_trig() { TEST_FLT_ACCURACY(cos(2*F(3.141592654)), 1.0, 0.01); \ TEST_FLT_NAN_ANY(cos(F(INFINITY))); \ TEST_FLT_NAN_ANY(cos(F(-INFINITY))); \ - TEST_FLT_NAN(cos(F(NAN)), F(NAN)) + TEST_FLT_NAN(cos(F(NAN)), F(NAN)); \ + TEST_FLT_NAN(cos(F(-NAN)), F(-NAN)) TEST_COS(cos); TEST_COS(cosf); TEST_COS(cosl); -#ifndef __OPTIMIZE__ - // GCC and Clang break this test when optimizing. - TEST_FLT_NAN(cos(F(-NAN)), F(-NAN)); - TEST_FLT_NAN(cosf(F(-NAN)), F(-NAN)); - TEST_FLT_NAN(cosl(F(-NAN)), F(-NAN)); -#endif - #define TEST_SIN(sin) \ TEST_FLT_ACCURACY(sin(F(0.0)), 0.0, 0.01); \ TEST_FLT_ACCURACY(sin(F(3.141592654)/2), 1.0, 0.01); \