https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77502
Rolf Eike Beer <e...@sf-mail.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |e...@sf-mail.de --- Comment #4 from Rolf Eike Beer <e...@sf-mail.de> --- Here is another case (all on a Gentoo system): buildbot@castor ~ $ cat gnull.cpp #include <glib.h> #include <gtk/gtk.h> void foo(GObject *g) { g_object_set_data(g, "b", GINT_TO_POINTER(FALSE)); } buildbot@castor ~ $ sparc-unknown-linux-gnu-gcc-8.3.0 $(pkg-config --cflags glib-2.0) $(pkg-config --cflags gtk+-2.0) -c -Wzero-as-null-pointer-constant gnull.cpp In file included from /usr/include/glib-2.0/glib/gtypes.h:32, from /usr/include/glib-2.0/glib/galloca.h:32, from /usr/include/glib-2.0/glib.h:30, from gnull.cpp:1: gnull.cpp: In function 'void foo(GObject*)': /usr/lib/glib-2.0/include/glibconfig.h:90:50: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant] #define GINT_TO_POINTER(i) ((gpointer) (glong) (i)) ^ gnull.cpp:6:31: note: in expansion of macro 'GINT_TO_POINTER' g_object_set_data(g, "b", GINT_TO_POINTER(FALSE)); Now with gcc 9.2. buildbot@castor ~ $ gcc $(pkg-config --cflags glib-2.0) $(pkg-config --cflags gtk+-2.0) -c -Wzero-as-null-pointer-constant gnull.cpp # no diagnostics, fine with me # and now I change the macro to use "glong" instead of "gint" in glibconfig.h I get different output (same for gcc 8 and 9): buildbot@castor ~ $ gcc $(pkg-config --cflags glib-2.0) $(pkg-config --cflags gtk+-2.0) -c -Wzero-as-null-pointer-constant gnull.cpp gnull.cpp: In function 'void foo(GObject*)': gnull.cpp:7:1: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant] 7 | } | ^ # that was my sparc with 32 bit userland, now my amd64 (openSUSE): gcc (SUSE Linux) 7.4.1 20190424 [gcc-7-branch revision 270538] eike@daneel:~$ gcc $(pkg-config --cflags glib-2.0) $(pkg-config --cflags gtk+-2.0) -c -Wzero-as-null-pointer-constant gnull.cpp In file included from /usr/include/glib-2.0/glib/gtypes.h:32:0, from /usr/include/glib-2.0/glib/galloca.h:32, from /usr/include/glib-2.0/glib.h:30, from gnull.cpp:1: gnull.cpp: In function ‘void foo(GObject*)’: /usr/lib64/glib-2.0/include/glibconfig.h:90:50: warning: zero as null pointer constant [-Wzero-as-null-pointer-constant] #define GINT_TO_POINTER(i) ((gpointer) (glong) (i)) ^ gnull.cpp:6:31: note: in expansion of macro ‘GINT_TO_POINTER’ g_object_set_data(g, "b", GINT_TO_POINTER(FALSE)); ^~~~~~~~~~~~~~~ When I have the relevant code in a greater function ( https://github.com/osm2go/osm2go/blob/6a7b955053ef9938f4be7b7ca8eacb99e4c426cf/src/platforms/gtk/osm_upload_dialog.cpp#L143 ) this does _not_ warn on my PC, but it warns on the sparc.