From 57c20be6ebeb9b21276beff145e68d7e095bcd02 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Mon, 4 Mar 2024 14:34:02 +0000 Subject: [PATCH] fix #7143: type punning in test --- src/test/hwf.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/hwf.cpp b/src/test/hwf.cpp index 8a019ec02b6..b81a9cef308 100644 --- a/src/test/hwf.cpp +++ b/src/test/hwf.cpp @@ -103,7 +103,9 @@ static void bug_to_rational() { static void bug_is_int() { unsigned raw_val[2] = { 2147483648u, 1077720461u }; - double val = *(double*)(raw_val); + double val; + static_assert(sizeof(raw_val) == sizeof(val)); + memcpy(&val, raw_val, sizeof(val)); std::cout << val << "\n"; hwf_manager m; hwf a;