[glib: 2/3] Silence MSVC C4312 in list tests
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] Silence MSVC C4312 in list tests
- Date: Thu, 16 Dec 2021 09:47:03 +0000 (UTC)
commit d60b4010c42e2d41b6b377c8977492bb7d6cdd8c
Author: Charles Barto <chbarto microsoft com>
Date: Wed Dec 15 17:21:20 2021 -0800
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 ())
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]