Re: g_object_ref() now propagates types
On Fri, Dec 8, 2017 at 6:26 AM, Philip Withnallwrote: > > child_type = CHILD_TYPE (g_object_ref (parent_type)); > > That will add a compile-time explicit cast, and a runtime type check. > (As always, the runtime type check is disabled if GLib is built without > debugging enabled (or with G_DISABLE_CAST_CHECKS defined.) > G_DISABLE_CAST_CHECKS is defined internally in GLib and GTK+ for stable releases (--enable-debug defaults to minimum for stable releases, yes for unstable releases), but that doesn't have any effect on whether they are enabled or disabled for your application; if you want to disable cast checks in production builds for your application, you need to specify G_DISABLE_CAST_CHECKS yourself. Owen ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: g_object_ref() now propagates types
On Sat, 2017-12-09 at 10:54 +0100, Sébastien Wilmet wrote: > On Fri, Dec 08, 2017 at 11:26:31AM +, Philip Withnall wrote: > > Note that the new behaviour requires GCC, and is only enabled if > > you > > have defined GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56. > > If GLIB_VERSION_MAX_ALLOWED is not defined, does it take by default > the > value of the last GLib version? That’s a good point. If left undefined, GLIB_VERSION_MAX_ALLOWED is defined to the current stable release (GLIB_VERSION_CUR_STABLE). Once 2.56 is released, that means anyone who has not defined GLIB_VERSION_MAX_ALLOWED will get the new g_object_ref() behaviour by default. Philip signature.asc Description: This is a digitally signed message part ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: g_object_ref() now propagates types
On Fri, Dec 08, 2017 at 11:26:31AM +, Philip Withnall wrote: > Note that the new behaviour requires GCC, and is only enabled if you > have defined GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56. If GLIB_VERSION_MAX_ALLOWED is not defined, does it take by default the value of the last GLib version? -- Sébastien ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: g_object_ref() now propagates types
On Fri, Dec 8, 2017 at 6:26 AM, Philip Withnallwrote: > Hi all, > > We just landed a patch in GLib which propagates the type from the > argument of g_object_ref() to its return type: > > https://git.gnome.org/browse/glib/commit/?id=3fae39a5d > https://bugzilla.gnome.org/show_bug.cgi?id=790697 > > The idea here is that it will catch invalid implicit casts which the > compiler otherwise wouldn’t have noticed because g_object_ref() > previously operated entirely on gpointers. This will eliminate a whole > class of bugs: bugs which are unlikely to exist, but are a complete > pain to track down if they do. > Great work. Another 3 or 4 or 200 of these and we'll almost have a C++ compiler! tongue firmly and warmly in cheek :))) ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: g_object_ref() now propagates types
On 8 December 2017 at 11:26, Philip Withnallwrote: > If anybody encounters any problems with this, please comment on the bug > report: > > https://bugzilla.gnome.org/show_bug.cgi?id=790697 As a side note: I've started a full Continuous rebuild, so if there are projects that indeed break with this change, we should be notified pretty quickly. Ciao, Emmanuele. -- https://www.bassi.io [@] ebassi [@gmail.com] ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list
g_object_ref() now propagates types
Hi all, We just landed a patch in GLib which propagates the type from the argument of g_object_ref() to its return type: https://git.gnome.org/browse/glib/commit/?id=3fae39a5d https://bugzilla.gnome.org/show_bug.cgi?id=790697 The idea here is that it will catch invalid implicit casts which the compiler otherwise wouldn’t have noticed because g_object_ref() previously operated entirely on gpointers. This will eliminate a whole class of bugs: bugs which are unlikely to exist, but are a complete pain to track down if they do. The downside of this is that some legitimate implicit casts may now cause compiler warnings with -Wincompatible-pointer-types. For example, in the situation below, a warning will be introduced since parent_type isn’t guaranteed to be an instance of child_type: ParentType *parent_type; ChildType *child_type; child_type = g_object_ref (parent_type); To fix this warning, first double-check that parent_type is actually guaranteed to always be an instance of child_type at runtime, and then change the ref to: child_type = CHILD_TYPE (g_object_ref (parent_type)); That will add a compile-time explicit cast, and a runtime type check. (As always, the runtime type check is disabled if GLib is built without debugging enabled (or with G_DISABLE_CAST_CHECKS defined.) Note that the new behaviour requires GCC, and is only enabled if you have defined GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56. If anybody encounters any problems with this, please comment on the bug report: https://bugzilla.gnome.org/show_bug.cgi?id=790697 Thanks, Philip on behalf of the GLib maintainership cabal signature.asc Description: This is a digitally signed message part ___ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list