From 8714b87dbe14dfc0c76a339c92e77c6f2b21981f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 15 May 2024 10:33:35 +0100 Subject: [PATCH] tests: Ignore -Wdiscarded-qualifiers with volatile atomics tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 14 now emits this warning with the tests: ``` In file included from ../glib/gthread.h:34, from ../glib/gasyncqueue.h:34, from ../glib/glib.h:34, from ../glib/tests/atomic.c:14: ../glib/tests/atomic.c: In function 'test_types': ../glib/gatomic.h:140:5: error: argument 2 of '__atomic_store' discards 'volatile' qualifier [-Werror=discarded-qualifiers] 140 | __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ | ^~~~~~~~~~~~~~ ../glib/tests/atomic.c:139:3: note: in expansion of macro 'g_atomic_pointer_set' 139 | g_atomic_pointer_set (&vp_str_vol, NULL); | ^~~~~~~~~~~~~~~~~~~~ cc1.exe: all warnings being treated as errors ``` I can’t think of a way to cast around this in the definition of `g_atomic_pointer_set()` without making the behaviour worse (less type safe) for modern non-volatile atomic variables. We would like to strongly nudge users of GLib away from declaring atomic variables as `volatile`, so letting another compiler warning be emitted when they do is not the end of the world. As long as it doesn’t stop old code compiling (without `-Werror`). Signed-off-by: Philip Withnall --- glib/tests/atomic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/glib/tests/atomic.c b/glib/tests/atomic.c index 9d57d2114..82c5c9e14 100644 --- a/glib/tests/atomic.c +++ b/glib/tests/atomic.c @@ -136,6 +136,7 @@ test_types (void) * to make sure that we don’t warn when built against older third party code. */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" +#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" g_atomic_pointer_set (&vp_str_vol, NULL); g_atomic_pointer_set (&vp_str, str); res = g_atomic_pointer_compare_and_exchange (&vp_str_vol, NULL, str);