After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796230 - gst-libs sdp: Function cast warnings in GCC 8
gst-libs sdp: Function cast warnings in GCC 8
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
unspecified
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 796237
Blocks:
 
 
Reported: 2018-05-18 08:06 UTC by Andreas Frisch
Modified: 2018-11-03 12:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sdpmessage: Avoid function cast warning in GCC 8 (974 bytes, patch)
2018-05-18 10:25 UTC, Andreas Frisch
reviewed Details | Review

Description Andreas Frisch 2018-05-18 08:06:59 UTC
/home/fraxinas/gst/master/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.h: In function 'glib_listautoptr_cleanup_GstSDPMessage':
/usr/include/glib-2.0/glib/gmacros.h:462:99: warning: cast between incompatible function types from 'GstSDPResult (*)(GstSDPMessage *)' {aka 'enum <anonymous> (*)(struct <anonymous> *)'} to 'void (*)(void *)' [-Wcast-function-type]
   static inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) func); } \
                                                                                                   ^
/home/fraxinas/gst/master/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.h:756:1: note: in expansion of macro 'G_DEFINE_AUTOPTR_CLEANUP_FUNC'
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSDPMessage, gst_sdp_message_free)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fraxinas/gst/master/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.h: In function 'glib_slistautoptr_cleanup_GstSDPMessage':
/usr/include/glib-2.0/glib/gmacros.h:463:102: warning: cast between incompatible function types from 'GstSDPResult (*)(GstSDPMessage *)' {aka 'enum <anonymous> (*)(struct <anonymous> *)'} to 'void (*)(void *)' [-Wcast-function-type]
   static inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) func); } \
                                                                                                      ^
/home/fraxinas/gst/master/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.h:756:1: note: in expansion of macro 'G_DEFINE_AUTOPTR_CLEANUP_FUNC'
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSDPMessage, gst_sdp_message_free)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~


This happens after upgrading from gcc 7.3.1+20180406-1 to 8.1.0-1


From https://gcc.gnu.org/gcc-8/changes.html 
-Wcast-function-type warns when a function pointer is cast to an incompatible function pointer. This warning is enabled by -Wextra.

1.4.0, 1.4.1 and master are all affected.
Comment 1 Sebastian Dröge (slomo) 2018-05-18 08:47:19 UTC
That's a false warning unfortunately, and the cast should've already prevented that. Returning something for a function that does not expect a return value is perfectly fine.

You could try to first cast the function to a gpointer and then to a GDestroyNotify there. Does that work?
Comment 2 Andreas Frisch 2018-05-18 10:25:36 UTC
Created attachment 372178 [details] [review]
sdpmessage: Avoid function cast warning in GCC 8
Comment 3 Jan Alexander Steffens (heftig) 2018-05-18 10:31:48 UTC
Maybe it would be worth patching this pattern into glib (like https://paste.xinu.at/zYR7Vn/ ) so that you can pass non-GDestroyNotify-compatible functions directly to G_DEFINE_AUTOPTR_CLEANUP_FUNC.
Comment 4 Sebastian Dröge (slomo) 2018-05-18 13:27:42 UTC
(In reply to Jan Alexander Steffens (heftig) from comment #3)
> Maybe it would be worth patching this pattern into glib (like
> https://paste.xinu.at/zYR7Vn/ ) so that you can pass
> non-GDestroyNotify-compatible functions directly to
> G_DEFINE_AUTOPTR_CLEANUP_FUNC.

Yes, please file another bug there :)
Comment 5 Sebastian Dröge (slomo) 2018-05-18 13:40:08 UTC
Review of attachment 372178 [details] [review]:

::: gst-libs/gst/sdp/gstsdpmessage.h
@@ +755,3 @@
 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
+static inline void _gst_autoptr_cleanup_sdp_message (GstSDPMessage *o) { gst_sdp_message_free (o); }
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSDPMessage, _gst_autoptr_cleanup_sdp_message)

Just casting the free function to a gpointer first and then to a GDestroyNotify is not enough?
Comment 6 Jan Alexander Steffens (heftig) 2018-05-18 13:45:46 UTC
(In reply to Sebastian Dröge (slomo) from comment #5)

No, it causes a different warning:

/home/fraxinas/gst/master/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.h: In function 'glib_autoptr_cleanup_GstSDPMessage':
/home/fraxinas/gst/master/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.h:756:46: warning: function called through a non-compatible type
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstSDPMessage, (GDestroyNotify) (gpointer) gst_sdp_message_free)
/usr/include/glib-2.0/glib/gmacros.h:461:88: note: in definition of macro 'G_DEFINE_AUTOPTR_CLEANUP_FUNC'
   static inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); }         \
Comment 7 Sebastian Dröge (slomo) 2018-05-23 16:26:38 UTC
Can you update your patch once the GLib people decided which variant they want? We shouldn't depend on the GLib change as that would require updating the GLib dependency for such a trivial thing.
Comment 8 Jan Alexander Steffens (heftig) 2018-05-23 17:27:55 UTC
Not sure what kind of update you're thinking of. Casting the function given to G_DEFINE_AUTOPTR_CLEANUP_FUNC isn't viable due to the above warning. Downstream of GLib we can either use the static wrapper or the pragmas from attachment 372034 [details] [review].
Comment 9 GStreamer system administrator 2018-11-03 12:07:33 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/456.