From d60b4010c42e2d41b6b377c8977492bb7d6cdd8c Mon Sep 17 00:00:00 2001 From: Charles Barto Date: Wed, 15 Dec 2021 17:21:20 -0800 Subject: [PATCH] Silence MSVC C4312 in list tests This warning warns on widening casts from integer to pointer type, because those casts can be problematic for porting to new pointer sizes. The code in question didn't do any bad things here so an intermediate cast to size_t was added to silence the warning --- glib/tests/list.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/glib/tests/list.c b/glib/tests/list.c index d34f1b84a..4efd8b625 100644 --- a/glib/tests/list.c +++ b/glib/tests/list.c @@ -532,7 +532,9 @@ static void test_double_free (void) { GList *list, *link; - GList intruder = { NULL, (gpointer)0xDEADBEEF, (gpointer)0xDEADBEEF }; + // Casts to size_t first ensure compilers won't warn about pointer casts that change size + // MSVC's C4312 warning with /Wp64 + GList intruder = { NULL, (gpointer)(size_t)0xDEADBEEF, (gpointer)(size_t)0xDEADBEEF }; if (g_test_subprocess ()) {