From 445dcd9d9b3bfe61da5860e6cc9f1e598a3ae376 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 18 Feb 2022 20:21:46 +0100 Subject: [PATCH] glib-aux: add NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER macro for workaround New gcc-12.0.1-0.8.fc36 on Fedora rawhide likes to emit false "-Wdangling-pointer" warnings with some g_error() uses. It seems related to g_error()'s `for(;;) ;`. As workaround, add a macro to suppress the warning. But only do that for gcc-12. This bug hopefully gets fixed and we don't want to suppress useful warnings too eagerly. https://bugzilla.redhat.com/show_bug.cgi?id=2056613 --- src/libnm-glib-aux/nm-macros-internal.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index eec3445972..3ccf9dea22 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -202,6 +202,18 @@ _nm_auto_freev(gpointer ptr) /*****************************************************************************/ +/* Seems gcc-12 has a tendency for false-positive -Wdangling-pointer warnings with + * g_error()'s `for(;;);`. + * + * Work around that, but it's only for gcc 12 (for now). */ +#if defined(__GNUC__) && __GNUC__ == 12 +#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_WARNING_DISABLE("-Wdangling-pointer") +#else +#define NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER NM_PRAGMA_DIAGNOSTICS_PUSH +#endif + +/*****************************************************************************/ + /** * NM_G_ERROR_MSG: * @error: (allow-none): the #GError instance