Macro cause warnings in C++ with -Wcast-qual
@hub
Submitted by Hubert Figuière Link to original bug (#757025)
Description
Created attachment 313945 glib-warnings.cpp reproducing case.
Compile the attached file with this (it is a .cpp, hence C++)
gcc -c glib-warnings.cpp `pkg-config --cflags glib-2.0` -Wcast-qual
It causes all these warnings:
In file included from /usr/include/glib-2.0/gio/gio.h:164:0,
from glib-warnings.cpp:3:
/usr/include/glib-2.0/gio/glistmodel.h: In function ‘GListModel* G_LIST_MODEL(gconstpointer)’:
/usr/include/glib-2.0/gio/glistmodel.h:36:397: warning: cast from type ‘gconstpointer {aka const void*}’ to type ‘GTypeInstance* {aka _GTypeInstance*}’ casts away qualifiers [-Wcast-qual]
/usr/include/glib-2.0/gio/glistmodel.h: In function ‘gboolean G_IS_LIST_MODEL(gconstpointer)’:
/usr/include/glib-2.0/gio/glistmodel.h:36:565: warning: cast from type ‘gconstpointer {aka const void*}’ to type ‘GTypeInstance* {aka _GTypeInstance*}’ casts away qualifiers [-Wcast-qual]
/usr/include/glib-2.0/gio/glistmodel.h: In function ‘GListModelInterface* G_LIST_MODEL_GET_IFACE(gconstpointer)’:
/usr/include/glib-2.0/gio/glistmodel.h:36:944: warning: cast from type ‘gconstpointer {aka const void*}’ to type ‘GTypeInstance* {aka _GTypeInstance*}’ casts away qualifiers [-Wcast-qual]
In file included from /usr/include/glib-2.0/gio/gio.h:165:0,
from glib-warnings.cpp:3:
/usr/include/glib-2.0/gio/gliststore.h: In function ‘GListStore* G_LIST_STORE(gconstpointer)’:
/usr/include/glib-2.0/gio/gliststore.h:36:403: warning: cast from type ‘gconstpointer {aka const void*}’ to type ‘GTypeInstance* {aka _GTypeInstance*}’ casts away qualifiers [-Wcast-qual]
/usr/include/glib-2.0/gio/gliststore.h: In function ‘gboolean G_IS_LIST_STORE(gconstpointer)’:
/usr/include/glib-2.0/gio/gliststore.h:36:571: warning: cast from type ‘gconstpointer {aka const void*}’ to type ‘GTypeInstance* {aka _GTypeInstance*}’ casts away qualifiers [-Wcast-qual]
This make building warning free code quite challenging.
Version 2.46.1 I believe it was already in 2.44
Attachment 313945, "glib-warnings.cpp reproducing case.":
glib-warnings.cpp
Version: 2.46.x
Edited by Philip Withnall