[Bug c++/77502] -Wzero-as-null-pointer-constant : misleading/imprecise messages

2019-10-08 Thread e...@sf-mail.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77502

Rolf Eike Beer  changed:

   What|Removed |Added

 CC||e...@sf-mail.de

--- Comment #4 from Rolf Eike Beer  ---
Here is another case (all on a Gentoo system):

buildbot@castor ~ $ cat gnull.cpp 
#include 
#include 

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.

[Bug c++/77502] -Wzero-as-null-pointer-constant : misleading/imprecise messages

2018-10-01 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77502

Eric Gallager  changed:

   What|Removed |Added

 CC||dmalcolm at gcc dot gnu.org,
   ||dodji at gcc dot gnu.org

--- Comment #3 from Eric Gallager  ---
cc-ing diagnostics maintainers

[Bug c++/77502] -Wzero-as-null-pointer-constant : misleading/imprecise messages

2017-08-22 Thread egallager at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77502

Eric Gallager  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-08-22
 CC||egallager at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Eric Gallager  ---
Confirmed that the location info ought to be improved.

[Bug c++/77502] -Wzero-as-null-pointer-constant : misleading/imprecise messages

2016-09-06 Thread petschy at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77502

--- Comment #1 from petschy at gmail dot com ---
I found another case: initializing an array of structs:

struct X
{
const char* p;
int i;
};

X x[] = {
{ "hello", 0 },
{ 0, 0 }, // !
{ 0, 0 }, // !
{ 0, 0 }  // !
}; // all 3 errors marked here