GNOME Bugzilla – Bug 710863
Missing cast for g_value_set_pointer() on generic property value
Last modified: 2018-05-22 14:58:07 UTC
If a generic class (with type parameter T) has a property of type T, the generated C code will use g_value_[get|set]_pointer() for the property marshalling. However, it will pass the value from the property’s getter method (which has return type gconstpointer) into g_value_set_pointer(), which takes a gpointer. This means GCC will complain about discarding the const qualifier from the pointer because Vala is violating the C type system. For example: public abstract class Folks.AbstractFieldDetails<T> : Object { public virtual T @value { get { return this._value; } construct set { this._value = value; } } } generates the following: static void _vala_folks_abstract_field_details_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) { … switch (property_id) { case FOLKS_ABSTRACT_FIELD_DETAILS_VALUE: g_value_set_pointer (value, folks_abstract_field_details_get_value (self)); break; … } } gconstpointer folks_abstract_field_details_get_value (FolksAbstractFieldDetails* self) { g_return_val_if_fail (self != NULL, NULL); return FOLKS_ABSTRACT_FIELD_DETAILS_GET_CLASS (self)->get_value (self); } This is with Vala 0.22.0.26-f79fe.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME'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.gnome.org/GNOME/vala/issues/413.